Split utils/general.py

This puts backend specific code in either the builder or scheduler
subpackage. This puts API specific code in the new web subpackage.
Lastly, any code shared between the API and backend is placed in the
common subpackage.
This commit is contained in:
mprahl
2020-01-03 09:11:44 -05:00
parent 1ab8aabd75
commit b0a27081f4
41 changed files with 1373 additions and 1353 deletions

View File

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
def deps_to_dict(deps, deps_type):
"""
Helper method to convert a Modulemd.Dependencies object to a dictionary.
:param Modulemd.Dependencies deps: the Modulemd.Dependencies object to convert
:param str deps_type: the type of dependency (buildtime or runtime)
:return: a dictionary with the keys as module names and values as a list of strings
:rtype dict
"""
names_func = getattr(deps, 'get_{}_modules'.format(deps_type))
streams_func = getattr(deps, 'get_{}_streams'.format(deps_type))
return {
module: streams_func(module)
for module in names_func()
}