This is a hack in order to make grobisplitter understand different

compression types from pungi output. Basically determine if the file
is ends with gz (oldstyle) or xz (newstyle) or neither. If it is gz
assume it is a gzip (HA!) or if it is xz assume it is LZMA (double
ha!) and bail if it is neither.

A proper fix would be to determine the file type holistically and pull
in the appropriate decompression as needed. However to quote Dante
from Clerks:  I'm not even supposed to be here today!

Signed-off-by: Stephen Smoogen <smooge@smoogespace.com>
This commit is contained in:
Stephen Smoogen 2021-05-20 15:37:09 -04:00
parent 06605d7d35
commit 7b5d4d5145

View file

@ -7,6 +7,7 @@ import shutil
import gi
import gzip
import librepo
import lzma
import hawkey
import tempfile
import os
@ -104,7 +105,15 @@ def _parse_repository_modular(repo_info,package_sack):
"""
cts = {}
idx = mmd.ModuleIndex()
with gzip.GzipFile(filename=repo_info['modules'], mode='r') as gzf:
myfile = repo_info['modules']
if myfile.endswith(".gz"):
openfunc=gzip.GzipFile
elif myfile.endswith(".xz"):
openfunc=lzma.LZMAFile
else:
print("This file type is not fixed in this hack. Please fix code. (2021-05-20)");
sys.exit(1)
with openfunc(filename=myfile, mode='r') as gzf:
mmdcts = gzf.read().decode('utf-8')
res, failures = idx.update_from_string(mmdcts, True)
if len(failures) != 0:
@ -190,7 +199,15 @@ def get_default_modules(directory):
if 'modules' not in repo_info:
return contents
idx = mmd.ModuleIndex()
with gzip.GzipFile(filename=repo_info['modules'], mode='r') as gzf:
myfile=repo_info['modules']
if myfile.endswith(".gz"):
openfunc=gzip.GzipFile
elif myfile.endswith(".xz"):
openfunc=lzma.LZMAFile
else:
print("This file type is not fixed in this hack. Please fix code. (2021-05-20)");
sys.exit(1)
with openfunc(filename=myfile, mode='r') as gzf:
mmdcts = gzf.read().decode('utf-8')
res, failures = idx.update_from_string(mmdcts, True)
if len(failures) != 0: