#1052 Clean some code
Merged 9 months ago by mprahl. Opened 9 months ago by cqi.
cqi/fm-orchestrator clean-code  into  master

@@ -114,13 +114,12 @@ 




- def _get_mmds_from_requires(session, requires, mmds, recursive=False,

+ def _get_mmds_from_requires(requires, mmds, recursive=False,

                              default_streams=None, raise_if_stream_ambigous=False):


      Helper method for get_mmds_required_by_module_recursively returning

      the list of module metadata objects defined by `requires` dict.


-     :param session: SQLAlchemy DB session.

      :param requires: Modulemd.Module requires or buildrequires.

      :param mmds: Dictionary with already handled name:streams as a keys and lists

          of resulting mmds as values.

@@ -164,13 +163,13 @@ 

          for mmd_list in added_mmds.values():

              for mmd in mmd_list:

                  for deps in mmd.get_dependencies():

-                     mmds = _get_mmds_from_requires(session, deps.get_requires(), mmds, True)

+                     mmds = _get_mmds_from_requires(deps.get_requires(), mmds, True)


      return mmds



  def get_mmds_required_by_module_recursively(

-         session, mmd, default_streams=None, raise_if_stream_ambigous=False):

+         mmd, default_streams=None, raise_if_stream_ambigous=False):


      Returns the list of Module metadata objects of all modules required while

      building the module defined by `mmd` module metadata. This presumes the

@@ -203,7 +202,7 @@ 

      # At first get all the buildrequires of the module of interest.

      for deps in mmd.get_dependencies():

          mmds = _get_mmds_from_requires(

-             session, deps.get_buildrequires(), mmds, False, default_streams,

+             deps.get_buildrequires(), mmds, False, default_streams,



      # Now get the requires of buildrequires recursively.

@@ -211,7 +210,7 @@ 

          for mmd in mmds[mmd_key]:

              for deps in mmd.get_dependencies():

                  mmds = _get_mmds_from_requires(

-                     session, deps.get_requires(), mmds, True, default_streams,

+                     deps.get_requires(), mmds, True, default_streams,



      # Make single list from dict of lists.

@@ -258,7 +257,7 @@ 

      # and add them to MMDResolver.

      mmd_resolver = MMDResolver()

      mmds_for_resolving = get_mmds_required_by_module_recursively(

-         session, current_mmd, default_streams, raise_if_stream_ambigous)

+         current_mmd, default_streams, raise_if_stream_ambigous)

      for m in mmds_for_resolving:



@@ -388,7 +388,7 @@ 

          buildopts = mmd.get_rpm_buildopts()

          buildopts["macros"] = buildopts.get("macros", "") + "\n\n%__spec_check_pre exit 0\n"


-     return submit_module_build(username, None, mmd, None, optional_params)

+     return submit_module_build(username, None, mmd, optional_params)



  _url_check_re = re.compile(r"^[^:/]+:.*$")

@@ -404,17 +404,16 @@ 

          url = "file://" + url

      mmd, scm = _fetch_mmd(url, branch, allow_local_url)


-     return submit_module_build(username, url, mmd, scm, optional_params)

+     return submit_module_build(username, url, mmd, optional_params)



- def submit_module_build(username, url, mmd, scm, optional_params=None):

+ def submit_module_build(username, url, mmd, optional_params=None):


      Submits new module build.


      :param str username: Username of the build's owner.

      :param str url: SCM URL of submitted build.

      :param Modulemd.Module mmd: Modulemd defining the build.

-     :param scm.SCM scm: SCM class representing the cloned git repo.

      :param dict optional_params: Dict with optional params for a build:

          - "local_build" (bool): The module is being built locally (the MBS is

            not running in infra, but on local developer's machine).

@@ -42,8 +42,7 @@ 


          mmd = module_build.mmd()

          module_build_service.utils.expand_mse_streams(db.session, mmd)

-         modules = module_build_service.utils.get_mmds_required_by_module_recursively(

-             db.session, mmd)

+         modules = module_build_service.utils.get_mmds_required_by_module_recursively(mmd)

          nsvcs = [":".join([m.get_name(), m.get_stream(), str(m.get_version()), m.get_context()])

                   for m in modules]

          return nsvcs