- logging.info(u"Parsing specification file: input ...")
-
- idx = self._get_type_index(u"input")
- if idx is None:
- raise PresentationError(u"No data to process.")
-
- try:
- for key, value in self._cfg_yaml[idx][u"general"].items():
- self._specification[u"input"][key] = value
- self._specification[u"input"][u"builds"] = dict()
-
- for job, builds in self._cfg_yaml[idx][u"builds"].items():
- if builds:
- if isinstance(builds, dict):
- build_end = builds.get(u"end", None)
- max_builds = builds.get(u"max-builds", None)
- reverse = bool(builds.get(u"reverse", False))
- try:
- build_end = int(build_end)
- except ValueError:
- # defined as a range <start, build_type>
- if build_end in (u"lastCompletedBuild",
- u"lastSuccessfulBuild"):
- reverse = True
- build_end = self._get_build_number(job, build_end)
- builds = [x for x in range(builds[u"start"],
- build_end + 1)
- if x not in builds.get(u"skip", list())]
- if reverse:
- builds.reverse()
- if max_builds and max_builds < len(builds):
- builds = builds[:max_builds]
- self._specification[u"input"][u"builds"][job] = list()
- for build in builds:
- self._specification[u"input"][u"builds"][job]. \
- append({u"build": build, u"status": None})
-
- else:
- logging.warning(
- f"No build is defined for the job {job}. Trying to "
- f"continue without it."
- )
+ 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()