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 /debian/lib/python/debian_linux/debian.py | |
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
Diffstat (limited to 'debian/lib/python/debian_linux/debian.py')
-rw-r--r-- | debian/lib/python/debian_linux/debian.py | 42 |
1 files changed, 24 insertions, 18 deletions
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): |