Bug#934273: python3-debian: please support parsing Source: package (version)
David Bremner
bremner at debian.org
Fri Aug 9 02:09:02 BST 2019
Stuart Prescott <stuart at debian.org> writes:
>
> Any opinions on whether it should return the data unparsed as
>
> source_package (version)
>
> or whether it should be clever enough to return a
>
> namedtuple(..., ['source', 'version'])
>
Hmm. I'm not (blush) familiar with named tuples. I was thinking
something simple-minded like the following. By all means feel free to do
the pythonic thing though.
import re
rex=re.compile('([^(\s]+)\s*[(]([^)]+)[)]$')
def parse_source(string):
matches=rex.match(string)
if matches:
return (matches.group(1),matches.group(2))
else:
return string
def test_parse_source_without():
assert parse_source('0xffff') == '0xffff'
def test_parse_source_with():
assert parse_source('0xffff (0.8-1)') == ('0xffff','0.8-1')
More information about the pkg-python-debian-maint
mailing list