mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-05 02:56:17 +01:00
Merge branch 'python3_archquery_module' of https://github.com/lethliel/osc
Initial port of the archquery module to python3 (ArchQuery.__init__, ArchQuery.read, and ArchQuery.canonname are ported - the rest is missing).
This commit is contained in:
commit
e580769757
@ -17,7 +17,7 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
self.fields = {}
|
self.fields = {}
|
||||||
#self.magic = None
|
#self.magic = None
|
||||||
#self.pkgsuffix = 'pkg.tar.gz'
|
#self.pkgsuffix = 'pkg.tar.gz'
|
||||||
self.pkgsuffix = 'arch'
|
self.pkgsuffix = b'arch'
|
||||||
|
|
||||||
def read(self, all_tags=True, self_provides=True, *extra_tags):
|
def read(self, all_tags=True, self_provides=True, *extra_tags):
|
||||||
# all_tags and *extra_tags are currently ignored
|
# all_tags and *extra_tags are currently ignored
|
||||||
@ -28,13 +28,13 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
fn = open('/dev/null', 'wb')
|
fn = open('/dev/null', 'wb')
|
||||||
pipe = subprocess.Popen(['tar', '-O', '-xf', self.__path, '.PKGINFO'], stdout=subprocess.PIPE, stderr=fn).stdout
|
pipe = subprocess.Popen(['tar', '-O', '-xf', self.__path, '.PKGINFO'], stdout=subprocess.PIPE, stderr=fn).stdout
|
||||||
for line in pipe.readlines():
|
for line in pipe.readlines():
|
||||||
line = line.rstrip().split(' = ', 2)
|
line = line.rstrip().split(b' = ', 2)
|
||||||
if len(line) == 2:
|
if len(line) == 2:
|
||||||
if not line[0] in self.fields:
|
if not line[0] in self.fields:
|
||||||
self.fields[line[0]] = []
|
self.fields[line[0].decode('ascii')] = []
|
||||||
self.fields[line[0]].append(line[1])
|
self.fields[line[0].decode('ascii')].append(line[1])
|
||||||
if self_provides:
|
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)
|
self.fields.setdefault('provides', []).append(prv)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -115,7 +115,8 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
|||||||
|
|
||||||
def canonname(self):
|
def canonname(self):
|
||||||
pkgver = self.fields['pkgver'][0] if 'pkgver' in self.fields else None
|
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):
|
def gettag(self, tag):
|
||||||
# implement me, if needed
|
# implement me, if needed
|
||||||
|
Loading…
Reference in New Issue
Block a user