debian/lib/python/debian_linux/debian.py: Allow parsing any file as changelog
This commit is contained in:
parent
09697cfec7
commit
354e9c4806
|
@ -47,6 +47,8 @@ linux (4.16-1~exp1) UNRELEASED; urgency=medium
|
||||||
* debian/lib/python/debian_linux/gencontrol.py: Allow overriding output
|
* debian/lib/python/debian_linux/gencontrol.py: Allow overriding output
|
||||||
filenames
|
filenames
|
||||||
* debian/lib/python/debian_linux/debian.py: Close changelog after parsing
|
* debian/lib/python/debian_linux/debian.py: Close changelog after parsing
|
||||||
|
* debian/lib/python/debian_linux/debian.py: Allow parsing any file as
|
||||||
|
changelog
|
||||||
|
|
||||||
-- Roger Shimizu <rogershimizu@gmail.com> Fri, 23 Mar 2018 21:10:34 +0900
|
-- Roger Shimizu <rogershimizu@gmail.com> Fri, 23 Mar 2018 21:10:34 +0900
|
||||||
|
|
||||||
|
|
|
@ -35,26 +35,32 @@ class Changelog(list):
|
||||||
self.distribution, self.source, self.version, self.urgency = \
|
self.distribution, self.source, self.version, self.urgency = \
|
||||||
distribution, source, version, urgency
|
distribution, source, version, urgency
|
||||||
|
|
||||||
def __init__(self, dir='', version=None):
|
def __init__(self, dir='', version=None, file=None):
|
||||||
if version is None:
|
if version is None:
|
||||||
version = Version
|
version = Version
|
||||||
with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f:
|
if file:
|
||||||
while True:
|
self._parse(version, file)
|
||||||
line = f.readline()
|
else:
|
||||||
if not line:
|
with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f:
|
||||||
break
|
self._parse(version, f)
|
||||||
match = self._re.match(line)
|
|
||||||
if not match:
|
def _parse(self, version, f):
|
||||||
continue
|
while True:
|
||||||
try:
|
line = f.readline()
|
||||||
v = version(match.group('version'))
|
if not line:
|
||||||
except Exception:
|
break
|
||||||
if not len(self):
|
match = self._re.match(line)
|
||||||
raise
|
if not match:
|
||||||
v = Version(match.group('version'))
|
continue
|
||||||
self.append(self.Entry(match.group('distribution'),
|
try:
|
||||||
match.group('source'), v,
|
v = version(match.group('version'))
|
||||||
match.group('urgency')))
|
except Exception:
|
||||||
|
if not len(self):
|
||||||
|
raise
|
||||||
|
v = Version(match.group('version'))
|
||||||
|
self.append(self.Entry(match.group('distribution'),
|
||||||
|
match.group('source'), v,
|
||||||
|
match.group('urgency')))
|
||||||
|
|
||||||
|
|
||||||
class Version(object):
|
class Version(object):
|
||||||
|
|
Loading…
Reference in New Issue