- try:
- self._cfg_yaml = load(self._cfg_file, Loader=FullLoader)
- except YAMLError as err:
- raise PresentationError(msg=u"An error occurred while parsing the "
- u"specification file.",
- details=repr(err))
+
+ # It always starts with environment.yaml file, it must be present.
+ spec_file = join(self._cfg_dir, u"environment.yaml")
+ logging.info(f"Reading {spec_file}")
+ if not exists(spec_file):
+ raise PresentationError(f"The file {spec_file} does not exist.")
+
+ with open(spec_file, u"r") as file_read:
+ try:
+ self._cfg_yaml = load(file_read, Loader=FullLoader)
+ except YAMLError as err:
+ raise PresentationError(
+ f"An error occurred while parsing the specification file "
+ f"{spec_file}",
+ details=repr(err)
+ )
+
+ # Load the other specification files specified in the environment.yaml
+ idx = self._get_type_index(u"environment")
+ if idx is None:
+ raise PresentationError(
+ f"No environment defined in the file {spec_file}"
+ )
+ for spec_file in self._cfg_yaml[idx].get(u"spec-files", tuple()):
+ logging.info(f"Reading {spec_file}")
+ if not exists(spec_file):
+ raise PresentationError(f"The file {spec_file} does not exist.")
+ spec = None
+ with open(spec_file, u"r") as file_read:
+ try:
+ spec = load(file_read, Loader=FullLoader)
+ except YAMLError as err:
+ raise PresentationError(
+ f"An error occurred while parsing the specification "
+ f"file {spec_file}",
+ details=repr(err)
+ )
+ if spec:
+ self._cfg_yaml.extend(spec)