Skip to content

Commit

Permalink
Merge pull request #399 from furlongm/lzma
Browse files Browse the repository at this point in the history
remove python2 lzma support
  • Loading branch information
furlongm authored Apr 9, 2022
2 parents 28555c9 + 95114b8 commit 8656e3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
17 changes: 3 additions & 14 deletions repos/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

import re
import tarfile
try:
import lzma
except ImportError:
try:
from backports import lzma
except ImportError:
lzma = None
from datetime import datetime
from io import BytesIO
from defusedxml.lxml import _etree as etree
Expand Down Expand Up @@ -571,19 +564,17 @@ def refresh_rpm_repo(repo):
"""

formats = [
'repodata/repomd.xml.xz'
'repodata/repomd.xml.bz2',
'repodata/repomd.xml.gz',
'repodata/repomd.xml',
'suse/repodata/repomd.xml.xz'
'suse/repodata/repomd.xml.bz2',
'suse/repodata/repomd.xml.gz',
'suse/repodata/repomd.xml',
'content',
]

if lzma is not None:
formats.insert(0, 'repodata/repomd.xml.xz')
formats.insert(4, 'suse/repodata/repomd.xml.xz')

check_for_mirrorlists(repo)
check_for_metalinks(repo)

Expand Down Expand Up @@ -626,9 +617,7 @@ def refresh_deb_repo(repo):
are and then downloads and extracts packages from those files.
"""

formats = ['Packages.bz2', 'Packages.gz', 'Packages']
if lzma is not None:
formats.insert(0, 'Packages.xz')
formats = ['Packages.xz', 'Packages.bz2', 'Packages.gz', 'Packages']

ts = datetime.now().replace(microsecond=0)
for mirror in repo.mirror_set.filter(refresh=True):
Expand Down
10 changes: 2 additions & 8 deletions util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
import bz2
import magic
import zlib
try:
import lzma
except ImportError:
try:
from backports import lzma
except ImportError:
lzma = None
import lzma
from colorama import Fore, Style
from enum import Enum
from hashlib import md5, sha1, sha256
Expand Down Expand Up @@ -193,7 +187,7 @@ def extract(data, fmt):
m = magic.open(magic.MAGIC_MIME)
m.load()
mime = m.buffer(data).split(';')[0]
if (mime == 'application/x-xz' or fmt.endswith('xz')) and lzma is not None:
if (mime == 'application/x-xz' or fmt.endswith('xz')):
return unxz(data)
elif mime == 'application/x-bzip2' or fmt.endswith('bz2'):
return bunzip2(data)
Expand Down

0 comments on commit 8656e3a

Please sign in to comment.