Improve initiating manifest parser from a package archive

This commit is contained in:
Ivan Kravets
2020-10-22 19:08:20 +03:00
parent 5d87fb8757
commit afd79f4655

View File

@@ -119,12 +119,13 @@ class ManifestParserFactory(object):
assert path.endswith("tar.gz") assert path.endswith("tar.gz")
with tarfile.open(path, mode="r:gz") as tf: with tarfile.open(path, mode="r:gz") as tf:
for t in sorted(ManifestFileType.items().values()): for t in sorted(ManifestFileType.items().values()):
try: for member in (t, "./" + t):
return ManifestParserFactory.new( try:
tf.extractfile(t).read().decode(), t return ManifestParserFactory.new(
) tf.extractfile(member).read().decode(), t
except KeyError: )
pass except KeyError:
pass
raise UnknownManifestError("Unknown manifest file type in %s archive" % path) raise UnknownManifestError("Unknown manifest file type in %s archive" % path)
@staticmethod @staticmethod