1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-14 09:36:21 +01:00

[python3] switch ArchQuery to bytestrings

decode explicit (ascii)
This commit is contained in:
lethliel 2018-12-13 14:47:48 +01:00 committed by Marco Strigl
parent 7bd9ca485d
commit 21eca9e3f1

View File

@ -17,7 +17,7 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
self.fields = {}
#self.magic = None
#self.pkgsuffix = 'pkg.tar.gz'
self.pkgsuffix = 'arch'
self.pkgsuffix = b'arch'
def read(self, all_tags=True, self_provides=True, *extra_tags):
# all_tags and *extra_tags are currently ignored
@ -28,13 +28,13 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
fn = open('/dev/null', 'wb')
pipe = subprocess.Popen(['tar', '-O', '-xf', self.__path, '.PKGINFO'], stdout=subprocess.PIPE, stderr=fn).stdout
for line in pipe.readlines():
line = line.rstrip().split(' = ', 2)
line = line.rstrip().split(b' = ', 2)
if len(line) == 2:
if not line[0] in self.fields:
self.fields[line[0]] = []
self.fields[line[0]].append(line[1])
self.fields[line[0].decode('ascii')] = []
self.fields[line[0].decode('ascii')].append(line[1])
if self_provides:
prv = '%s = %s' % (self.name(), self.fields['pkgver'][0])
prv = b'%s = %s' % (self.name(), self.fields['pkgver'][0])
self.fields.setdefault('provides', []).append(prv)
return self
@ -115,7 +115,8 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
def canonname(self):
pkgver = self.fields['pkgver'][0] if 'pkgver' in self.fields else None
return self.name() + '-' + pkgver + '-' + self.arch() + '.' + self.pkgsuffix
canonname = self.name() + b'-' + pkgver + b'-' + self.arch() + b'.' + self.pkgsuffix
return canonname
def gettag(self, tag):
# implement me, if needed