def _LoadArtifactsFromFiles(self, file_paths, overwrite_if_exists=True):
    """Load artifacts from file paths as json or yaml."""
    loaded_files = []
    loaded_artifacts = []
    for file_path in file_paths:
      try:
        with io.open(file_path, mode="r", encoding="utf-8") as fh:
          logging.debug("Loading artifacts from %s", file_path)
          for artifact_val in self.ArtifactsFromYaml(fh.read()):
            self.RegisterArtifact(
                artifact_val,
                source="file:%s" % file_path,
                overwrite_if_exists=overwrite_if_exists)
            loaded_artifacts.append(artifact_val)
            logging.debug("Loaded artifact %s from %s", artifact_val.name,
                          file_path)

        loaded_files.append(file_path)
      except (IOError, OSError) as e:
        logging.error("Failed to open artifact file %s. %s", file_path, e)
      except rdf_artifacts.ArtifactDefinitionError as e:
        logging.error("Invalid artifact found in file %s with error: %s",
                      file_path, e)
        raise

    # Once all artifacts are loaded we can validate.
    for artifact_value in loaded_artifacts:
      Validate(artifact_value)
def _LoadArtifactsFromFiles ( self , file_paths , overwrite_if_exists = True ) : loaded_files = [ ] loaded_artifacts = [ ] for file_path in file_paths : try : with io . open ( file_path , mode = "r" , encoding = "utf-8" ) as fh : logging . debug ( "Loading artifacts from %s" , file_path ) for artifact_val in self . ArtifactsFromYaml ( fh . read ( ) ) : self . RegisterArtifact ( artifact_val , source = "file:%s" % file_path , overwrite_if_exists = overwrite_if_exists ) loaded_artifacts . append ( artifact_val ) logging . debug ( "Loaded artifact %s from %s" , artifact_val . name , file_path ) loaded_files . append ( file_path ) except ( IOError , OSError ) as e : logging . error ( "Failed to open artifact file %s. %s" , file_path , e ) except rdf_artifacts . ArtifactDefinitionError as e : logging . error ( "Invalid artifact found in file %s with error: %s" , file_path , e ) raise for artifact_value in loaded_artifacts : Validate ( artifact_value )
Load artifacts from file paths as json or yaml.