Create method for loading modulemd object from yaml

This commit is contained in:
Jakub Kadlčík
2017-02-17 00:14:30 +01:00
parent 52ace7f671
commit 1591b9c5e7

View File

@@ -287,12 +287,7 @@ def _fetch_mmd(url, allow_local_url = False):
"Failed to remove temporary directory {!r}: {}".format(
td, str(e)))
mmd = modulemd.ModuleMetadata()
try:
mmd.loads(yaml)
except Exception as e:
log.error('Invalid modulemd: %s' % str(e))
raise UnprocessableEntity('Invalid modulemd: %s' % str(e))
mmd = load_mmd(yaml)
# If undefined, set the name field to VCS repo name.
if not mmd.name and scm:
@@ -308,6 +303,17 @@ def _fetch_mmd(url, allow_local_url = False):
return mmd, scm, yaml
def load_mmd(yaml):
mmd = modulemd.ModuleMetadata()
try:
mmd.loads(yaml)
except Exception as e:
log.error('Invalid modulemd: %s' % str(e))
raise UnprocessableEntity('Invalid modulemd: %s' % str(e))
return mmd
def _scm_get_latest(pkg):
try:
# If the modulemd specifies that the 'f25' branch is what