diff options
Diffstat (limited to 'releaselog/__init__.py')
-rw-r--r-- | releaselog/__init__.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/releaselog/__init__.py b/releaselog/__init__.py index e4a04c5..015f796 100644 --- a/releaselog/__init__.py +++ b/releaselog/__init__.py @@ -39,13 +39,20 @@ class Release(object): class ReleaseHistory(object): """ReleaseHistory - base class for ReleaseLog implementations - Attributes: + Class Attributes: + + format - array of names for this format + filename - name of the file normally used to keep the log file - history - a list of Release objects header - a compiled regular expression that returns a match for history entry heading lines end_of_entry_rx - a compiled regular expression returning a match for end of entry. Can be None + + Instance Attributes: + + history - a list of Release objects. Normally not needed, since + it is accessed by indexing the object. """ history = [] @@ -63,10 +70,10 @@ class ReleaseHistory(object): if isinstance(arg, Release): self.history.append(arg) else: - raise TypeError() + raise TypeError('argument to append must be a Release') def parse_header(self, line): - """Matche input line against the history header regexp. On match, + """Match input line against the history header regexp. On match, return a tuple (date, version, startdescr), where date is the release date (datetime), version is the release version number, and startdescr is the first line of the description or None. @@ -121,6 +128,8 @@ class ReleaseHistory(object): Entries are numbered from 0. """ + self.history = [] + date = None version = None descr = [] @@ -136,7 +145,7 @@ class ReleaseHistory(object): elif kw == 'count': count = val else: - raise TypeError() # FIXME + raise KeyError ('keyword %s is not known' % kw) if count: if start: @@ -247,7 +256,12 @@ class ReleaseLog(object): rev[cls.formatdb[fmt]] = [] rev[cls.formatdb[fmt]].append(fmt) return rev.values() - + + @classmethod + def filename(cls, name): + """Returns the accepted log file name for the given format.""" + return cls.formatdb[name].filename + # Initialize the ReleaseLog implementations import pkgutil |