mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-24 11:12:14 +01:00
Replace double with single underscores to avoid name mangling
This commit is contained in:
parent
a6fd4f88d3
commit
bcdc3b1835
@ -41,28 +41,28 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, fh):
|
def __init__(self, fh):
|
||||||
self.__file = fh
|
self._file = fh
|
||||||
self.__path = os.path.abspath(fh.name)
|
self._path = os.path.abspath(fh.name)
|
||||||
self.filename_suffix = 'deb'
|
self.filename_suffix = 'deb'
|
||||||
self.fields = {}
|
self.fields = {}
|
||||||
|
|
||||||
def read(self, all_tags=False, self_provides=True, *extra_tags):
|
def read(self, all_tags=False, self_provides=True, *extra_tags):
|
||||||
arfile = ar.Ar(fh=self.__file)
|
arfile = ar.Ar(fh=self._file)
|
||||||
arfile.read()
|
arfile.read()
|
||||||
debbin = arfile.get_file(b'debian-binary')
|
debbin = arfile.get_file(b'debian-binary')
|
||||||
if debbin is None:
|
if debbin is None:
|
||||||
raise DebError(self.__path, 'no debian binary')
|
raise DebError(self._path, 'no debian binary')
|
||||||
if debbin.read() != b'2.0\n':
|
if debbin.read() != b'2.0\n':
|
||||||
raise DebError(self.__path, 'invalid debian binary format')
|
raise DebError(self._path, 'invalid debian binary format')
|
||||||
for open_func in [self.__open_tar_gz,
|
for open_func in [self._open_tar_gz,
|
||||||
self.__open_tar_xz,
|
self._open_tar_xz,
|
||||||
self.__open_tar_zst,
|
self._open_tar_zst,
|
||||||
self.__open_tar]:
|
self._open_tar]:
|
||||||
tar = open_func(arfile)
|
tar = open_func(arfile)
|
||||||
if tar is not None:
|
if tar is not None:
|
||||||
break
|
break
|
||||||
if tar is None:
|
if tar is None:
|
||||||
raise DebError(self.__path, 'missing control.tar')
|
raise DebError(self._path, 'missing control.tar')
|
||||||
try:
|
try:
|
||||||
name = './control'
|
name = './control'
|
||||||
# workaround for python2.4's tarfile module
|
# workaround for python2.4's tarfile module
|
||||||
@ -70,46 +70,46 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
name = 'control'
|
name = 'control'
|
||||||
control = tar.extractfile(name)
|
control = tar.extractfile(name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise DebError(self.__path,
|
raise DebError(self._path,
|
||||||
'missing \'control\' file in control.tar')
|
'missing \'control\' file in control.tar')
|
||||||
self.__parse_control(control, all_tags, self_provides, *extra_tags)
|
self._parse_control(control, all_tags, self_provides, *extra_tags)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __open_tar(self, arfile):
|
def _open_tar(self, arfile):
|
||||||
control = arfile.get_file(b'control.tar')
|
control = arfile.get_file(b'control.tar')
|
||||||
if control:
|
if control:
|
||||||
# XXX: python2.4 relies on a name
|
# XXX: python2.4 relies on a name
|
||||||
return tarfile.open(name="control.tar", fileobj=control)
|
return tarfile.open(name="control.tar", fileobj=control)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __open_tar_gz(self, arfile):
|
def _open_tar_gz(self, arfile):
|
||||||
control = arfile.get_file(b'control.tar.gz')
|
control = arfile.get_file(b'control.tar.gz')
|
||||||
if control:
|
if control:
|
||||||
return tarfile.open(name='control.tar.gz', fileobj=control)
|
return tarfile.open(name='control.tar.gz', fileobj=control)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __open_tar_xz(self, arfile):
|
def _open_tar_xz(self, arfile):
|
||||||
control = arfile.get_file(b'control.tar.xz')
|
control = arfile.get_file(b'control.tar.xz')
|
||||||
if control:
|
if control:
|
||||||
if not HAVE_LZMA:
|
if not HAVE_LZMA:
|
||||||
raise DebError(self.__path, 'can\'t open control.tar.xz without python-lzma')
|
raise DebError(self._path, 'can\'t open control.tar.xz without python-lzma')
|
||||||
decompressed = lzma.decompress(control.read())
|
decompressed = lzma.decompress(control.read())
|
||||||
return tarfile.open(name="control.tar.xz",
|
return tarfile.open(name="control.tar.xz",
|
||||||
fileobj=BytesIO(decompressed))
|
fileobj=BytesIO(decompressed))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __open_tar_zst(self, arfile):
|
def _open_tar_zst(self, arfile):
|
||||||
control = arfile.get_file(b'control.tar.zst')
|
control = arfile.get_file(b'control.tar.zst')
|
||||||
if control:
|
if control:
|
||||||
if not HAVE_ZSTD:
|
if not HAVE_ZSTD:
|
||||||
raise DebError(self.__path, 'can\'t open control.tar.zst without python-zstandard')
|
raise DebError(self._path, 'can\'t open control.tar.zst without python-zstandard')
|
||||||
with zstandard.ZstdDecompressor().stream_reader(BytesIO(control.read())) as reader:
|
with zstandard.ZstdDecompressor().stream_reader(BytesIO(control.read())) as reader:
|
||||||
decompressed = reader.read()
|
decompressed = reader.read()
|
||||||
return tarfile.open(name="control.tar.zst",
|
return tarfile.open(name="control.tar.zst",
|
||||||
fileobj=BytesIO(decompressed))
|
fileobj=BytesIO(decompressed))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __parse_control(self, control, all_tags=False, self_provides=True, *extra_tags):
|
def _parse_control(self, control, all_tags=False, self_provides=True, *extra_tags):
|
||||||
data = control.readline().strip()
|
data = control.readline().strip()
|
||||||
while data:
|
while data:
|
||||||
field, val = re.split(br':\s*', data.strip(), 1)
|
field, val = re.split(br':\s*', data.strip(), 1)
|
||||||
@ -178,7 +178,7 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
return self.fields[b'description']
|
return self.fields[b'description']
|
||||||
|
|
||||||
def path(self):
|
def path(self):
|
||||||
return self.__path
|
return self._path
|
||||||
|
|
||||||
def provides(self):
|
def provides(self):
|
||||||
return self.fields[b'provides']
|
return self.fields[b'provides']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user