Skip to content

Commit

Permalink
Use libmodulemd to open module metadata files
Browse files Browse the repository at this point in the history
Libmodulemd can auto-detect compression

re: #8700
https://pulp.plan.io/issues/8700
  • Loading branch information
dralley committed May 6, 2021
1 parent 121ccac commit 2a0bfe6
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pulp_rpm/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import asyncio
import collections
import gzip
import logging
import lzma
import os
import re
import tempfile
Expand Down Expand Up @@ -759,16 +757,7 @@ def parse(self):
"""Parse module.yaml, if exists, to create relations between packages."""
if self.modulemd_result:
modulemd_index = mmdlib.ModuleIndex.new()
if self.modulemd_result.url.endswith(".gz"):
open_func = gzip.open
elif self.modulemd_result.url.endswith(".xz"):
open_func = lzma.open
else:
open_func = open
with open_func(self.modulemd_result.path, "r") as moduleyaml:
content = moduleyaml.read()
module_content = content if isinstance(content, str) else content.decode()
modulemd_index.update_from_string(module_content, True)
modulemd_index.update_from_file(self.modulemd_result.path, True)

self._parse_modulemd_list(modulemd_index)
self._parse_modulemd_default_names(modulemd_index)
Expand Down

0 comments on commit 2a0bfe6

Please sign in to comment.