/usr/lib/python3/dist-packages/pyroma/distributiondata.py is in python3-pyroma 2.0.0b2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # Extracts information from a distribution file by unpacking in a temporary
# directory and then using projectdata on that.
import os
import shutil
import tempfile
import zipfile
import tarfile
from pyroma import projectdata
def get_data(path):
filename = os.path.split(path)[-1]
basename, ext = os.path.splitext(filename)
if basename.endswith('.tar'):
basename, ignored = os.path.splitext(basename)
try:
tempdir = tempfile.mkdtemp()
if ext in ('.bz2', '.tbz', 'tb2', '.gz', '.tgz', '.tar'):
tarfile.open(name=path, mode='r:*').extractall(tempdir)
elif ext in ('.zip', '.egg'):
zipfile.ZipFile(path, mode='r').extractall(tempdir)
else:
raise ValueError('Unknown file type: ' + ext)
projectpath = os.path.join(tempdir, basename)
data = projectdata.get_data(projectpath)
finally:
shutil.rmtree(tempdir)
return data
|