aboutsummaryrefslogtreecommitdiffstats
path: root/debian/lib/python/debian_linux/debian.py
diff options
context:
space:
mode:
authorBastian Blank <waldi@debian.org>2007-01-27 21:20:16 +0000
committerBastian Blank <waldi@debian.org>2007-01-27 21:20:16 +0000
commit60506c6fefa1bb2093cbb2d7d9d7aac0a63f5430 (patch)
tree8369b3d0946e39c339404a6d257e551fee6b7ba5 /debian/lib/python/debian_linux/debian.py
parent5be1182aea4c6127abb5e425f94ac7d02df807fc (diff)
downloadkernel_replicant_linux-60506c6fefa1bb2093cbb2d7d9d7aac0a63f5430.tar.gz
kernel_replicant_linux-60506c6fefa1bb2093cbb2d7d9d7aac0a63f5430.tar.bz2
kernel_replicant_linux-60506c6fefa1bb2093cbb2d7d9d7aac0a63f5430.zip
debian/bin/gencontrol.py, debian/lib/python/debian_linux/debian.py:
Make changelog code object oriented. svn path=/dists/trunk/linux-2.6/; revision=8234
Diffstat (limited to 'debian/lib/python/debian_linux/debian.py')
-rw-r--r--debian/lib/python/debian_linux/debian.py86
1 files changed, 43 insertions, 43 deletions
diff --git a/debian/lib/python/debian_linux/debian.py b/debian/lib/python/debian_linux/debian.py
index a868344a173c..23e865da9701 100644
--- a/debian/lib/python/debian_linux/debian.py
+++ b/debian/lib/python/debian_linux/debian.py
@@ -1,51 +1,51 @@
import itertools, os.path, re, utils
-def read_changelog(dir = '', version = None):
- r = re.compile(r"""
+class Changelog(list):
+ _rules = r"""
^
-(
-(?P<header>
- (?P<header_source>
- \w[-+0-9a-z.]+
- )
- \
- \(
- (?P<header_version>
- [^\(\)\ \t]+
- )
- \)
- \s+
- (?P<header_distribution>
- [-0-9a-zA-Z]+
- )
- \;
+(?P<source>
+ \w[-+0-9a-z.]+
)
+\
+\(
+(?P<version>
+ [^\(\)\ \t]+
+)
+\)
+\s+
+(?P<distribution>
+ [-0-9a-zA-Z]+
)
-""", re.VERBOSE)
- if version is None:
- version = Version
- f = file(os.path.join(dir, "debian/changelog"))
- entries = []
- while True:
- line = f.readline()
- if not line:
- break
- line = line.strip('\n')
- match = r.match(line)
- if not match:
- continue
- if match.group('header'):
- e = {}
- e['Distribution'] = match.group('header_distribution')
- e['Source'] = match.group('header_source')
- try:
- e['Version'] = version(match.group('header_version'))
- except Exception:
- if not len(entries):
- raise
- e['Version'] = Version(match.group('header_version'))
- entries.append(e)
- return entries
+\;
+"""
+ _re = re.compile(_rules, re.X)
+
+ class Entry(object):
+ __slot__ = 'distribution', 'source', 'version'
+
+ def __init__(self, distribution, source, version):
+ self.distribution, self.source, self.version = distribution, source, version
+
+ def __init__(self, dir = '', version = None):
+ if version is None:
+ version = Version
+ f = file(os.path.join(dir, "debian/changelog"))
+ while True:
+ line = f.readline()
+ if not line:
+ break
+ line = line.strip('\n')
+ match = self._re.match(line)
+ if not match:
+ continue
+ if match.group('version'):
+ 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))
class Version(object):
_version_rules = ur"""