#1230 Reuse function load_mmd Part 2
Merged 4 years ago by mprahl. Opened 4 years ago by mprahl.

@@ -36,7 +36,7 @@ 

  from module_build_service.utils import (

      submit_module_build_from_yaml,

      load_local_builds,

-     load_mmd,

+     load_mmd_file,

      import_mmd,

      import_builds_from_local_dnf_repos,

  )
@@ -104,7 +104,7 @@ 

  def import_module(mmd_file):

      """ Imports the module from mmd_file

      """

-     mmd = load_mmd(mmd_file, is_file=True)

+     mmd = load_mmd_file(mmd_file)

      import_mmd(db.session, mmd)

  

  

@@ -42,6 +42,7 @@ 

  import module_build_service.messaging

  from module_build_service.glib import from_variant_dict

  from module_build_service import db, log, get_url_for, app, conf

+ from module_build_service.errors import UnprocessableEntity

  

  DEFAULT_MODULE_CONTEXT = "00000000"

  
@@ -492,7 +493,7 @@ 

  

          try:

              return load_mmd(self.modulemd)

-         except Exception:

+         except UnprocessableEntity:

              log.exception("An error occurred while trying to parse the modulemd")

              raise ValueError("Invalid modulemd")

  
@@ -546,7 +547,7 @@ 

  

          try:

              mmd = load_mmd(mmd_str)

-         except Exception:

+         except UnprocessableEntity:

              raise ValueError("Invalid modulemd")

          mbs_xmd = mmd.get_xmd().get("mbs", {})

          rv = []

@@ -28,7 +28,7 @@ 

  from abc import ABCMeta, abstractmethod

  

  import module_build_service.config as cfg

- from module_build_service import conf, log

+ from module_build_service import conf

  

  

  class GenericResolver(six.with_metaclass(ABCMeta)):
@@ -98,16 +98,6 @@ 

  

          return False

  

-     @staticmethod

-     def extract_modulemd(yaml, strict=False):

-         log.warning(

-             "GenericResolver.extract_modulemd is deprecated. Please call "

-             "module_build_service.utils.load_mmd in new code."

-         )

-         from module_build_service.utils import load_mmd

- 

-         return load_mmd(yaml)

- 

      @abstractmethod

      def get_module_count(self, **kwargs):

          raise NotImplementedError()

@@ -875,7 +875,7 @@ 

          if not whitelist_url and mandatory_checks:

              scm.verify()

          cofn = scm.get_module_yaml()

-         mmd = load_mmd(cofn, is_file=True)

+         mmd = load_mmd_file(cofn)

      finally:

          try:

              if td is not None:
@@ -1021,7 +1021,7 @@ 

  

          # Load the modulemd metadata.

          path = os.path.join(conf.mock_resultsdir, found_build[3], "results")

-         mmd = load_mmd(os.path.join(path, "modules.yaml"), is_file=True)

+         mmd = load_mmd_file(os.path.join(path, "modules.yaml"))

  

          # Create ModuleBuild in database.

          module = models.ModuleBuild.create(

5 new commits added

  • Remove extract_modulemd since it's no longer used in the code
  • Return an empty list if no results are found in MBSResolver._get_modules and strict is False
  • Catch invalid modulemd exceptions using UnprocessableEntity instead of Exception
  • Use load_mmd_file instead of load_mmd where possible
  • Reuse function load_mmd
4 years ago

rebased onto d652788f9c2c690355d9816dafe28f8a334f7a84

4 years ago

rebased onto d652788f9c2c690355d9816dafe28f8a334f7a84

4 years ago

rebased onto 6c8d482

4 years ago

Pull-Request has been merged by mprahl

4 years ago