/usr/lib/python3/dist-packages/dep11/utils.py is in python3-dep11 0.4.0-1build1.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/env python
#
# Copyright (c) 2014-2015 Matthias Klumpp <mak@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program.
import gzip
from apt_pkg import TagFile, version_compare
def str_enc_dec(val):
'''
Handles encoding decoding for localized values.
'''
if isinstance(val, str):
val = bytes(val, 'utf-8')
val = val.decode("utf-8", "replace")
return val
def read_packages_dict_from_file(archive_root, suite, component, arch):
source_path = archive_root + "/dists/%s/%s/binary-%s/Packages.gz" % (suite, component, arch)
f = gzip.open(source_path, 'rb')
tagf = TagFile(f)
package_dict = dict()
for section in tagf:
pkg = dict()
pkg['arch'] = section['Architecture']
pkg['version'] = section['Version']
pkg['name'] = section['Package']
if not section.get('Filename'):
print("Package %s-%s has no filename specified." % (pkg['name'], pkg['version']))
continue
pkg['filename'] = section['Filename']
pkg['maintainer'] = section['Maintainer']
pkg2 = package_dict.get(pkg['name'])
if pkg2:
compare = version_compare(pkg2['version'], pkg['version'])
if compare >= 0:
continue
package_dict[pkg['name']] = pkg
return package_dict
def build_cpt_global_id(cptid, checksum):
if (not checksum) or (not cptid):
return None
gid = None
parts = None
if cptid.startswith(("org.", "net.", "com.", "io.")):
parts = cptid.split(".", 2)
if parts and len(parts) > 2:
gid = "%s/%s/%s/%s" % (parts[0].lower(), parts[1], parts[2], checksum)
else:
gid = "%s/%s/%s" % (cptid[0].lower(), cptid, checksum)
return gid
|