diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-08-27 19:57:34 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-08-27 20:01:19 +0300 |
commit | a5bde557e0f8848983c7b5151615571483f76cec (patch) | |
tree | 3e5b8d3ead41c78462901af1c945234e8ca0118a | |
parent | 2e6def2e969656e496a82c6d041a7b52d7f52086 (diff) | |
download | releaselogparser-a5bde557e0f8848983c7b5151615571483f76cec.tar.gz releaselogparser-a5bde557e0f8848983c7b5151615571483f76cec.tar.bz2 |
Housekeeping changes.
* .gitignore: New file.
* releaselog.py: Rename to bin/releaselog.
* releaselog/__init__.py (filename): New ReleaseLog class method.
* releaselog/format/__init__.py: Update.
* releaselog/format/cpan.py: Define the filename attribute.
* releaselog/format/gnu.py: Likewise.
* releaselog/format/python.py: Likewise.
* setup.py: New file.
-rw-r--r-- | .gitignore | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | bin/releaselog (renamed from releaselog.py) | 0 | ||||
-rw-r--r-- | releaselog/__init__.py | 26 | ||||
-rw-r--r-- | releaselog/format/__init__.py | 8 | ||||
-rw-r--r-- | releaselog/format/cpan.py | 1 | ||||
-rw-r--r-- | releaselog/format/gnu.py | 1 | ||||
-rw-r--r-- | releaselog/format/python.py | 1 | ||||
-rw-r--r-- | setup.py | 48 |
8 files changed, 83 insertions, 9 deletions
@@ -1,4 +1,7 @@ | |||
1 | *~ | 1 | *~ |
2 | .emacs* | ||
3 | *.pyc | 2 | *.pyc |
4 | /tmp | 3 | .emacs.desktop |
4 | build/ | ||
5 | dist/ | ||
6 | tmp/ | ||
7 | *.egg-info/ | ||
diff --git a/releaselog.py b/bin/releaselog index c535a08..c535a08 100644..100755 --- a/releaselog.py +++ b/bin/releaselog | |||
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): | |||
39 | class ReleaseHistory(object): | 39 | class ReleaseHistory(object): |
40 | """ReleaseHistory - base class for ReleaseLog implementations | 40 | """ReleaseHistory - base class for ReleaseLog implementations |
41 | 41 | ||
42 | Attributes: | 42 | Class Attributes: |
43 | |||
44 | format - array of names for this format | ||
45 | filename - name of the file normally used to keep the log file | ||
43 | 46 | ||
44 | history - a list of Release objects | ||
45 | header - a compiled regular expression that returns a match for | 47 | header - a compiled regular expression that returns a match for |
46 | history entry heading lines | 48 | history entry heading lines |
47 | end_of_entry_rx - a compiled regular expression returning a match for | 49 | end_of_entry_rx - a compiled regular expression returning a match for |
48 | end of entry. Can be None | 50 | end of entry. Can be None |
51 | |||
52 | Instance Attributes: | ||
53 | |||
54 | history - a list of Release objects. Normally not needed, since | ||
55 | it is accessed by indexing the object. | ||
49 | """ | 56 | """ |
50 | 57 | ||
51 | history = [] | 58 | history = [] |
@@ -63,10 +70,10 @@ class ReleaseHistory(object): | |||
63 | if isinstance(arg, Release): | 70 | if isinstance(arg, Release): |
64 | self.history.append(arg) | 71 | self.history.append(arg) |
65 | else: | 72 | else: |
66 | raise TypeError() | 73 | raise TypeError('argument to append must be a Release') |
67 | 74 | ||
68 | def parse_header(self, line): | 75 | def parse_header(self, line): |
69 | """Matche input line against the history header regexp. On match, | 76 | """Match input line against the history header regexp. On match, |
70 | return a tuple (date, version, startdescr), where date is the | 77 | return a tuple (date, version, startdescr), where date is the |
71 | release date (datetime), version is the release version number, and | 78 | release date (datetime), version is the release version number, and |
72 | startdescr is the first line of the description or None. | 79 | startdescr is the first line of the description or None. |
@@ -121,6 +128,8 @@ class ReleaseHistory(object): | |||
121 | 128 | ||
122 | Entries are numbered from 0. | 129 | Entries are numbered from 0. |
123 | """ | 130 | """ |
131 | self.history = [] | ||
132 | |||
124 | date = None | 133 | date = None |
125 | version = None | 134 | version = None |
126 | descr = [] | 135 | descr = [] |
@@ -136,7 +145,7 @@ class ReleaseHistory(object): | |||
136 | elif kw == 'count': | 145 | elif kw == 'count': |
137 | count = val | 146 | count = val |
138 | else: | 147 | else: |
139 | raise TypeError() # FIXME | 148 | raise KeyError ('keyword %s is not known' % kw) |
140 | 149 | ||
141 | if count: | 150 | if count: |
142 | if start: | 151 | if start: |
@@ -247,7 +256,12 @@ class ReleaseLog(object): | |||
247 | rev[cls.formatdb[fmt]] = [] | 256 | rev[cls.formatdb[fmt]] = [] |
248 | rev[cls.formatdb[fmt]].append(fmt) | 257 | rev[cls.formatdb[fmt]].append(fmt) |
249 | return rev.values() | 258 | return rev.values() |
250 | 259 | ||
260 | @classmethod | ||
261 | def filename(cls, name): | ||
262 | """Returns the accepted log file name for the given format.""" | ||
263 | return cls.formatdb[name].filename | ||
264 | |||
251 | 265 | ||
252 | # Initialize the ReleaseLog implementations | 266 | # Initialize the ReleaseLog implementations |
253 | import pkgutil | 267 | import pkgutil |
diff --git a/releaselog/format/__init__.py b/releaselog/format/__init__.py index 67d9bac..a5e8ea0 100644 --- a/releaselog/format/__init__.py +++ b/releaselog/format/__init__.py | |||
@@ -5,10 +5,16 @@ To implement a new format, drop into this directory a python source defining | |||
5 | a subclass of ReleaseHistory with the new implementation. The name for the | 5 | a subclass of ReleaseHistory with the new implementation. The name for the |
6 | new format must be defined in the 'format' subclass attribute. This attribute | 6 | new format must be defined in the 'format' subclass attribute. This attribute |
7 | can be either a string or a list of strings. Use the latter form to define | 7 | can be either a string or a list of strings. Use the latter form to define |
8 | aliases. For example | 8 | aliases. |
9 | |||
10 | The name of the file normally used to keep release history in this format | ||
11 | must be stored in the 'filename' attribute. | ||
12 | |||
13 | For example | ||
9 | 14 | ||
10 | class NewHistoryFormat(ReleaseHistory): | 15 | class NewHistoryFormat(ReleaseHistory): |
11 | format = 'newformat' | 16 | format = 'newformat' |
17 | filename = 'HISTORY.txt' | ||
12 | ... | 18 | ... |
13 | 19 | ||
14 | See the ReleaseHistory documentation for details. | 20 | See the ReleaseHistory documentation for details. |
diff --git a/releaselog/format/cpan.py b/releaselog/format/cpan.py index deec1f7..d6ffb78 100644 --- a/releaselog/format/cpan.py +++ b/releaselog/format/cpan.py | |||
@@ -16,5 +16,6 @@ from releaselog import ReleaseHistory | |||
16 | 16 | ||
17 | class ReleaseLogFormat(ReleaseHistory): | 17 | class ReleaseLogFormat(ReleaseHistory): |
18 | format = ['CPAN', 'Changes'] | 18 | format = ['CPAN', 'Changes'] |
19 | filename = 'Changes' | ||
19 | header = re.compile('^(?P<version>\d[\d.]*)\s+(?P<date>.+?)\s*$') | 20 | header = re.compile('^(?P<version>\d[\d.]*)\s+(?P<date>.+?)\s*$') |
20 | 21 | ||
diff --git a/releaselog/format/gnu.py b/releaselog/format/gnu.py index 1b5894b..503a7de 100644 --- a/releaselog/format/gnu.py +++ b/releaselog/format/gnu.py | |||
@@ -16,6 +16,7 @@ from releaselog import ReleaseHistory | |||
16 | 16 | ||
17 | class ReleaseLogFormat(ReleaseHistory): | 17 | class ReleaseLogFormat(ReleaseHistory): |
18 | format = ['GNU', 'NEWS'] | 18 | format = ['GNU', 'NEWS'] |
19 | filename = 'NEWS' | ||
19 | header = re.compile(r"""^(?:\*\s+)? # optional initial section | 20 | header = re.compile(r"""^(?:\*\s+)? # optional initial section |
20 | (?:(?i)version)\s+ | 21 | (?:(?i)version)\s+ |
21 | (?P<version>\d(?:[.,]\d+){1,2} # At least MAJOR.MINOR | 22 | (?P<version>\d(?:[.,]\d+){1,2} # At least MAJOR.MINOR |
diff --git a/releaselog/format/python.py b/releaselog/format/python.py index bdcdea6..cd742cc 100644 --- a/releaselog/format/python.py +++ b/releaselog/format/python.py | |||
@@ -28,6 +28,7 @@ from releaselog import ReleaseHistory | |||
28 | 28 | ||
29 | class PythonLogFormat(ReleaseHistory): | 29 | class PythonLogFormat(ReleaseHistory): |
30 | format = ['Python', 'python'] | 30 | format = ['Python', 'python'] |
31 | filename = 'CHANGES.txt' | ||
31 | header = None | 32 | header = None |
32 | header_rx = [ | 33 | header_rx = [ |
33 | re.compile("""^[vV](?P<version>\d[\d.]*)\s* | 34 | re.compile("""^[vV](?P<version>\d[\d.]*)\s* |
diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9844af3 --- /dev/null +++ b/setup.py | |||
@@ -0,0 +1,48 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # -*- coding: utf-8 -*- | ||
3 | # Copyright (C) 2008-2018 Sergey Poznyakoff | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 3, or (at your option) | ||
8 | # any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | from setuptools import setup, find_packages | ||
19 | from codecs import open | ||
20 | |||
21 | #with open("README.rst", "r") as fh: | ||
22 | # long_description = fh.read() | ||
23 | |||
24 | setup(name='releaselog', | ||
25 | version='0.2', | ||
26 | author='Sergey Poznyakoff', | ||
27 | author_email='gray@gnu.org', | ||
28 | url='http://git.gnu.org.ua/cgit/gsc/releaselog.git/', | ||
29 | packages = find_packages(exclude=['contrib', 'docs', | ||
30 | 'tests', 'testdata']), | ||
31 | scripts=['bin/releaselog'], | ||
32 | license='GPL License', | ||
33 | description='Release log parser.', | ||
34 | # long_description=long_description, | ||
35 | # long_description_content_type="text/x-rst", | ||
36 | platforms=['any'], | ||
37 | # test_suite='tests', | ||
38 | classifiers=[ | ||
39 | 'Development Status :: 4 - Beta', | ||
40 | 'Intended Audience :: Developers', | ||
41 | 'License :: OSI Approved :: GNU General Public License (GPL)', | ||
42 | 'Operating System :: OS Independent', | ||
43 | 'Programming Language :: Python', | ||
44 | 'Topic :: Software Development :: Libraries :: Python Modules', | ||
45 | 'Topic :: Text Processing :: General' | ||
46 | ], | ||
47 | keywords = 'release log history changes news', | ||
48 | ) | ||