Files
fm-orchestrator/module_build_service/web/utils.py
mprahl b0a27081f4 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.
2020-03-03 14:48:47 -05:00

20 lines
672 B
Python

# -*- 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()
}