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 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'))
|
||||
|
||||
|
||||
@ -91,18 +93,18 @@ def request_staged(request):
|
||||
def binary_list(apiurl, project, repository, arch, package=None):
|
||||
parsed = []
|
||||
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:
|
||||
continue
|
||||
|
||||
name = result.group(1)
|
||||
name = result.group('name')
|
||||
if name.endswith('-debuginfo') or name.endswith('-debuginfo-32bit'):
|
||||
continue
|
||||
if name.endswith('-debugsource'):
|
||||
continue
|
||||
if result.group(4) == 'src':
|
||||
if result.group('arch') == 'src':
|
||||
continue
|
||||
|
||||
parsed.append(BinaryParsed(binary, name, result.group(4)))
|
||||
parsed.append(BinaryParsed(result.group('filename'), name, result.group('arch')))
|
||||
|
||||
return parsed
|
||||
|
Loading…
x
Reference in New Issue
Block a user