summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-08-25 23:53:52 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-08-25 23:53:52 (GMT)
commit2e6def2e969656e496a82c6d041a7b52d7f52086 (patch) (side-by-side diff)
treeede427b425a434755ede74b62e1cb6acb60a37cd
parent5b49acb829c3fd077f7946ef8a3ba6ee3d6de888 (diff)
downloadreleaselogparser-2e6def2e969656e496a82c6d041a7b52d7f52086.tar.gz
releaselogparser-2e6def2e969656e496a82c6d041a7b52d7f52086.tar.bz2
Add support for python-style release logs
* releaselog.py: New option --list * releaselog/__init__.py (ReleaseLog): New class method: formats * releaselog/format/python.py: New source.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--releaselog.py11
-rw-r--r--releaselog/__init__.py13
-rw-r--r--releaselog/format/python.py4
3 files changed, 26 insertions, 2 deletions
diff --git a/releaselog.py b/releaselog.py
index c8eeff3..c535a08 100644
--- a/releaselog.py
+++ b/releaselog.py
@@ -37,8 +37,19 @@ def main():
parser.add_option('-u', '--url',
action="store_true", dest='url',
help='treat ARG as URL')
+ parser.add_option('-l', '--list',
+ action="store_true", dest='list',
+ help="list supported formats")
(options, args) = parser.parse_args()
+ if options.list:
+ for f in ReleaseLogFile.formats():
+ if len(f) > 1:
+ print("%s; %s" % (f[0], ', '.join(f[1:])))
+ else:
+ print("%s" % f[0])
+ sys.exit(0)
+
if len(args) != 1:
parser.error("bad number of arguments")
diff --git a/releaselog/__init__.py b/releaselog/__init__.py
index 7cb9c7d..e4a04c5 100644
--- a/releaselog/__init__.py
+++ b/releaselog/__init__.py
@@ -236,6 +236,19 @@ class ReleaseLog(object):
else:
cls.formatdb[fmt] = impl
+ @classmethod
+ def formats(cls):
+ """Return a list of supported release log formats. Each item in
+ the list is a list of alternative format names.
+ """
+ rev = {}
+ for fmt in cls.formatdb:
+ if cls.formatdb[fmt] not in rev:
+ rev[cls.formatdb[fmt]] = []
+ rev[cls.formatdb[fmt]].append(fmt)
+ return rev.values()
+
+
# Initialize the ReleaseLog implementations
import pkgutil
import importlib
diff --git a/releaselog/format/python.py b/releaselog/format/python.py
index 7c2a218..bdcdea6 100644
--- a/releaselog/format/python.py
+++ b/releaselog/format/python.py
@@ -15,8 +15,8 @@ may follow.
<Version> (<Date>)
-followed by the description text. This format is used, among others, by
-GNU Texinfo.
+followed by the description text. Incidentally, this format is used by some
+non-Python software, such as e.g. GNU Texinfo.
The PythonLogFormat class discovers the actual format by finding the first
input line that matches any of the above patterns.

Return to:

Send suggestions and report system problems to the System administrator.