pkgset: Check for empty module index
Instead of testing its return value. Future version of libmodulemd will raise an exception instead of returning empty data. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
c6d6367932
commit
b514e20833
@ -231,14 +231,14 @@ def create_variant_repo(compose, arch, variant, pkg_type, modules_metadata=None)
|
|||||||
|
|
||||||
def add_modular_metadata(repo, repo_path, mod_index, log_file):
|
def add_modular_metadata(repo, repo_path, mod_index, log_file):
|
||||||
"""Add modular metadata into a repository."""
|
"""Add modular metadata into a repository."""
|
||||||
|
# Dumping empty index fails, we need to check for that.
|
||||||
|
if not mod_index.get_module_names():
|
||||||
|
return
|
||||||
|
|
||||||
with temp_dir() as tmp_dir:
|
with temp_dir() as tmp_dir:
|
||||||
modules_path = os.path.join(tmp_dir, "modules.yaml")
|
modules_path = os.path.join(tmp_dir, "modules.yaml")
|
||||||
data = mod_index.dump_to_string()
|
|
||||||
if not data:
|
|
||||||
# No data to include...
|
|
||||||
return
|
|
||||||
with open(modules_path, "w") as f:
|
with open(modules_path, "w") as f:
|
||||||
f.write(data)
|
f.write(mod_index.dump_to_string())
|
||||||
|
|
||||||
cmd = repo.get_modifyrepo_cmd(
|
cmd = repo.get_modifyrepo_cmd(
|
||||||
os.path.join(repo_path, "repodata"),
|
os.path.join(repo_path, "repodata"),
|
||||||
|
Loading…
Reference in New Issue
Block a user