+ # Replace ranges by lists
+ for set_name, data_set in self.data_sets.items():
+ if not isinstance(data_set, dict):
+ continue
+ for job, builds in data_set.items():
+ if not builds:
+ continue
+ if isinstance(builds, dict):
+ build_end = builds.get(u"end", None)
+ max_builds = builds.get(u"max-builds", None)
+ reverse = builds.get(u"reverse", False)
+ try:
+ build_end = int(build_end)
+ except ValueError:
+ # defined as a range <start, build_type>
+ build_end = self._get_build_number(job, build_end)
+ builds = list(range(builds[u"start"], build_end + 1))
+ if max_builds and max_builds < len(builds):
+ builds = builds[-max_builds:]
+ if reverse:
+ builds.reverse()
+ self.data_sets[set_name][job] = builds
+ elif isinstance(builds, list):
+ for idx, item in enumerate(builds):
+ try:
+ builds[idx] = int(item)
+ except ValueError:
+ # defined as a range <build_type>
+ builds[idx] = self._get_build_number(job, item)
+
+ # Add sub-sets to sets (only one level):
+ for set_name, data_set in self.data_sets.items():
+ if isinstance(data_set, list):
+ new_set = dict()
+ for item in data_set:
+ try:
+ for key, val in self.data_sets[item].items():
+ new_set[key] = val
+ except KeyError:
+ raise PresentationError(
+ f"Data set {item} is not defined."
+ )
+ self.data_sets[set_name] = new_set
+
+ def _load_mapping_table(self):
+ """Load a mapping table if it is specified. If not, use empty dict.
+ """
+
+ mapping_file_name = self.environment.get(u"mapping-file", None)
+ if mapping_file_name:
+ try:
+ with open(mapping_file_name, u'r') as mfile:
+ mapping = load(mfile, Loader=FullLoader)
+ # Make sure everything is lowercase
+ self.environment[u"mapping"] = \
+ {key.lower(): val.lower() for key, val in
+ mapping.items()}
+ logging.debug(f"Loaded mapping table:\n{mapping}")
+ except (YAMLError, IOError) as err:
+ raise PresentationError(
+ msg=f"An error occurred while parsing the mapping file "
+ f"{mapping_file_name}",
+ details=repr(err)
+ )
+ else:
+ self.environment[u"mapping"] = dict()
+
+ def _load_ignore_list(self):
+ """Load an ignore list if it is specified. If not, use empty list.
+ """
+
+ ignore_list_name = self.environment.get(u"ignore-list", None)
+ if ignore_list_name:
+ try:
+ with open(ignore_list_name, u'r') as ifile:
+ ignore = load(ifile, Loader=FullLoader)
+ # Make sure everything is lowercase
+ self.environment[u"ignore"] = \
+ [item.lower() for item in ignore]
+ logging.debug(f"Loaded ignore list:\n{ignore}")
+ except (YAMLError, IOError) as err:
+ raise PresentationError(
+ msg=f"An error occurred while parsing the ignore list file "
+ f"{ignore_list_name}.",
+ details=repr(err)
+ )
+ else:
+ self.environment[u"ignore"] = list()