aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rwxr-xr-x[-rw-r--r--]bin/releaselog (renamed from releaselog.py)0
-rw-r--r--releaselog/__init__.py26
-rw-r--r--releaselog/format/__init__.py8
-rw-r--r--releaselog/format/cpan.py1
-rw-r--r--releaselog/format/gnu.py1
-rw-r--r--releaselog/format/python.py1
-rw-r--r--setup.py48
8 files changed, 83 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index ed0a9ff..5f2763b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
*~
-.emacs*
*.pyc
-/tmp
+.emacs.desktop
+build/
+dist/
+tmp/
+*.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):
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
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
a subclass of ReleaseHistory with the new implementation. The name for the
new format must be defined in the 'format' subclass attribute. This attribute
can be either a string or a list of strings. Use the latter form to define
-aliases. For example
+aliases.
+
+The name of the file normally used to keep release history in this format
+must be stored in the 'filename' attribute.
+
+For example
class NewHistoryFormat(ReleaseHistory):
format = 'newformat'
+ filename = 'HISTORY.txt'
...
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
class ReleaseLogFormat(ReleaseHistory):
format = ['CPAN', 'Changes']
+ filename = 'Changes'
header = re.compile('^(?P<version>\d[\d.]*)\s+(?P<date>.+?)\s*$')
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
class ReleaseLogFormat(ReleaseHistory):
format = ['GNU', 'NEWS']
+ filename = 'NEWS'
header = re.compile(r"""^(?:\*\s+)? # optional initial section
(?:(?i)version)\s+
(?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
class PythonLogFormat(ReleaseHistory):
format = ['Python', 'python']
+ filename = 'CHANGES.txt'
header = None
header_rx = [
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 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2008-2018 Sergey Poznyakoff
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from setuptools import setup, find_packages
+from codecs import open
+
+#with open("README.rst", "r") as fh:
+# long_description = fh.read()
+
+setup(name='releaselog',
+ version='0.2',
+ author='Sergey Poznyakoff',
+ author_email='gray@gnu.org',
+ url='http://git.gnu.org.ua/cgit/gsc/releaselog.git/',
+ packages = find_packages(exclude=['contrib', 'docs',
+ 'tests', 'testdata']),
+ scripts=['bin/releaselog'],
+ license='GPL License',
+ description='Release log parser.',
+# long_description=long_description,
+# long_description_content_type="text/x-rst",
+ platforms=['any'],
+ # test_suite='tests',
+ classifiers=[
+ 'Development Status :: 4 - Beta',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: GNU General Public License (GPL)',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Software Development :: Libraries :: Python Modules',
+ 'Topic :: Text Processing :: General'
+ ],
+ keywords = 'release log history changes news',
+)

Return to:

Send suggestions and report system problems to the System administrator.