mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
[python3] now python3 ready:
* new function cmp (not available in python3) * fix decoding in canonname function
This commit is contained in:
parent
8b4dae21f7
commit
c235148180
@ -5,6 +5,10 @@ import os
|
||||
import re
|
||||
import struct
|
||||
from . import packagequery
|
||||
from osc.util.helper import decode_it
|
||||
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
|
||||
class RpmError(packagequery.PackageError):
|
||||
pass
|
||||
@ -184,14 +188,14 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
||||
continue
|
||||
# RPMSENSE_SENSEMASK = 15 (see rpmlib.h) but ignore RPMSENSE_SERIAL (= 1 << 0) therefore use 14
|
||||
if flags & 14:
|
||||
name += ' '
|
||||
name += b' '
|
||||
if flags & self.GREATER:
|
||||
name += '>'
|
||||
name += b'>'
|
||||
elif flags & self.LESS:
|
||||
name += '<'
|
||||
name += b'<'
|
||||
if flags & self.EQUAL:
|
||||
name += '='
|
||||
name += ' %s' % ver
|
||||
name += b'='
|
||||
name += b' %s' % ver
|
||||
res.append(name)
|
||||
return res
|
||||
|
||||
@ -288,7 +292,7 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
||||
arch = 'src'
|
||||
else:
|
||||
arch = self.arch()
|
||||
return RpmQuery.filename(self.name(), None, self.version(), self.release(), arch)
|
||||
return RpmQuery.filename(decode_it(self.name()), None, decode_it(self.version()), decode_it(self.release()), decode_it(arch))
|
||||
|
||||
@staticmethod
|
||||
def query(filename):
|
||||
@ -318,6 +322,8 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
|
||||
if ver1 == ver2:
|
||||
return 0
|
||||
res = 0
|
||||
ver1 = decode_it(ver1)
|
||||
ver2 = decode_it(ver2)
|
||||
while res == 0:
|
||||
# remove all leading non alphanumeric or tilde chars
|
||||
ver1 = re.sub('^[^a-zA-Z0-9~]*', '', ver1)
|
||||
|
Loading…
Reference in New Issue
Block a user