diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2018-04-06 12:13:37 +0200 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-04-08 10:31:19 +0200 |
commit | 354e9c4806d7116380cd8c19f3bf2d387d622089 (patch) | |
tree | 35d200aef081a22a704f56dc0f01932eacd15473 | |
parent | 09697cfec76ea4b68d0e16931cce4dc87038ab83 (diff) | |
download | kernel_replicant_linux-354e9c4806d7116380cd8c19f3bf2d387d622089.tar.gz kernel_replicant_linux-354e9c4806d7116380cd8c19f3bf2d387d622089.tar.bz2 kernel_replicant_linux-354e9c4806d7116380cd8c19f3bf2d387d622089.zip |
debian/lib/python/debian_linux/debian.py: Allow parsing any file as changelog
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | debian/lib/python/debian_linux/debian.py | 42 |
2 files changed, 26 insertions, 18 deletions
diff --git a/debian/changelog b/debian/changelog index f13f9305856d..50e7d9197692 100644 --- a/debian/changelog +++ b/debian/changelog @@ -47,6 +47,8 @@ linux (4.16-1~exp1) UNRELEASED; urgency=medium * debian/lib/python/debian_linux/gencontrol.py: Allow overriding output filenames * 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 diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py index 6f40c6222f63..de8171c0ebc6 100644 --- a/debian/lib/python/debian_linux/debian.py +++ b/debian/lib/python/debian_linux/debian.py @@ -35,26 +35,32 @@ class Changelog(list): self.distribution, self.source, self.version, self.urgency = \ distribution, source, version, urgency - def __init__(self, dir='', version=None): + def __init__(self, dir='', version=None, file=None): if version is None: version = Version - with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f: - while True: - line = f.readline() - if not line: - break - match = self._re.match(line) - if not match: - continue - try: - v = version(match.group('version')) - 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'))) + if file: + self._parse(version, file) + else: + with open(os.path.join(dir, "debian/changelog"), encoding="UTF-8") as f: + self._parse(version, f) + + def _parse(self, version, f): + while True: + line = f.readline() + if not line: + break + match = self._re.match(line) + if not match: + continue + try: + v = version(match.group('version')) + 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): |