osclib/core: provide BINARY_REGEX named group pattern and utilize.
This commit is contained in:
parent
cfbd479ed7
commit
5e120a6ac4
@ -12,6 +12,8 @@ from osc.core import owner
|
|||||||
from osc.core import show_project_meta
|
from osc.core import show_project_meta
|
||||||
from osclib.memoize import memoize
|
from osclib.memoize import memoize
|
||||||
|
|
||||||
|
BINARY_REGEX = r'(?:.*::)?(?P<filename>(?P<name>.*?)-(?P<version>[^-]+)-(?P<release>[^-]+)\.(?P<arch>[^-\.]+))'
|
||||||
|
RPM_REGEX = BINARY_REGEX + '\.rpm'
|
||||||
BinaryParsed = namedtuple('BinaryParsed', ('filename', 'name', 'arch'))
|
BinaryParsed = namedtuple('BinaryParsed', ('filename', 'name', 'arch'))
|
||||||
|
|
||||||
|
|
||||||
@ -91,18 +93,18 @@ def request_staged(request):
|
|||||||
def binary_list(apiurl, project, repository, arch, package=None):
|
def binary_list(apiurl, project, repository, arch, package=None):
|
||||||
parsed = []
|
parsed = []
|
||||||
for binary in get_binarylist(apiurl, project, repository, arch, package):
|
for binary in get_binarylist(apiurl, project, repository, arch, package):
|
||||||
result = re.match(r'(.*)-([^-]*)-([^-]*)\.([^-\.]+)\.rpm', binary)
|
result = re.match(RPM_REGEX, binary)
|
||||||
if not result:
|
if not result:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
name = result.group(1)
|
name = result.group('name')
|
||||||
if name.endswith('-debuginfo') or name.endswith('-debuginfo-32bit'):
|
if name.endswith('-debuginfo') or name.endswith('-debuginfo-32bit'):
|
||||||
continue
|
continue
|
||||||
if name.endswith('-debugsource'):
|
if name.endswith('-debugsource'):
|
||||||
continue
|
continue
|
||||||
if result.group(4) == 'src':
|
if result.group('arch') == 'src':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
parsed.append(BinaryParsed(binary, name, result.group(4)))
|
parsed.append(BinaryParsed(result.group('filename'), name, result.group('arch')))
|
||||||
|
|
||||||
return parsed
|
return parsed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user