python-debian Changelog module?
jsw at debian.org
jsw at debian.org
Wed Aug 31 09:02:17 UTC 2011
Hi Mark,
(Adding the project mailing list.)
On Tue, Aug 30, 2011 at 01:19:33PM +0000, Mark Kusch wrote:
> Hi,
>
> I wonder how python-debian Changelog module should be used to read and parse data from changelog files.
>
> It simply does not work, reproducable:
> - create changelog file with "simple_changelog" from examples folder
> $ /usr/share/doc/python-debian/examples/changelog/simple_changelog > /tmp/python-debian-test.changelog
> - gather information from generated changelog file
> >>> from debian.changelog import Changelog, Version
> >>> chlog = Changelog('/tmp/python-debian-test.changelog')
> >>> chlog.get_version()
The Changelog constructor takes the changelog contents as an iterable of
str or unicode lines (e.g. a file object), or a single str or unicode.
It doesn't take a filename. You want something like
>>> from debian import changelog
>>> f = open('/tmp/python-debian-test.changelog')
>>> c = changelog.Changelog(f)
>>> c.get_version()
Version('0.1')
It seems pretty clear in the docs:
>>> help(changelog.Changelog)
Help on class Changelog in module debian.changelog:
class Changelog(__builtin__.object)
| Represents a debian/changelog file.
|
| Methods defined here:
|
| __init__(self, file=None, max_blocks=None, allow_empty_author=False, strict=True, encoding='utf-8')
| Initializer.
|
| Args:
| file: The contents of the changelog, either as a str, unicode object,
| or an iterator of lines (each of which is either a str or unicode)
Unfortunately, you have to get at them with an interactive interpreter
or by examining the source. We probably should be putting epydoc output
in /usr/share/doc/python-debian.
> --------------------------------------------------------------------------
> IndexError Traceback (most recent call last)
>
> /usr/lib/pymodules/python2.5/debian/changelog.pyc in get_version(self)
> 393 def get_version(self):
> 394 """Return a Version object for the last version"""
> --> 395 return self._blocks[0].version
> 396
> 397 def set_version(self, version):
>
> IndexError: list index out of range
>
>
> Problem for me is in Changelog.parse_changelog().
> >>> chlog.parse_changelog('/tmp/python-debian-test.changelog')
> ---------------------------------------------------------------------------
> ChangelogParseError Traceback (most recent call last)
>
> /usr/lib/pymodules/python2.5/debian/changelog.pyc in parse_changelog(self, file, max_blocks, allow_empty_author, strict)
> 325 continue
> 326 self._parse_error("Unexpected line while looking "
> --> 327 "for %s: %s" % (state, line), strict)
> 328 if state == first_heading:
> 329 self.initial_blank_lines.append(line)
>
> /usr/lib/pymodules/python2.5/debian/changelog.pyc in _parse_error(self, message, strict)
> 214 def _parse_error(self, message, strict):
> 215 if strict:
> --> 216 raise ChangelogParseError(message)
> 217 else:
> 218 warnings.warn(message)
>
> ChangelogParseError: Could not parse changelog: Unexpected line while looking for first heading: /tmp/python-debian-test.changelog
>
>
> I've tried instances of Changelog with
> - max_blocks set (e.g. 3) and default None
> - allow_empty_author True and False
> - strict True and False
>
> in Debian package versions
> - oldstable (0.1.10)
> - lenny-backports (0.1.14~bpo50+1)
> - wheezy (0.1.21)
>
> in Debian Lenny on
> - changelogs generated through debian.changelog.Changelog()
> - changelogs from Debian packages (upstream)
> - changelogs from own custom packages (following the Debian Policy chapter 4.4 "Debian changelog: debian/changelog" in http://www.debian.org/doc/debian-policy/ch-source.html)
>
> No success at all. Because there is no time for me at work to "fix" something upstream and send in patches I hope you can help me out or possibly find problems in python-debian
> which can get fixed upstream.
>
> Best,
>
> # kraM
>
> --
> Mark Kusch
> System Administration
>
> Bigpoint GmbH
> Drehbahn 47-48
> 20354 Hamburg | Germany
>
> Tel: +49 (0)40 / 88 14 13 - 353
> Fax: +49 (0)40 / 88 14 13 - 7353
> E-Mail: m.kusch at bigpoint.net
>
> CEO: Heiko Hubertz
> Register: HRB-Hamburg 94148
--
John Wright <jsw at debian.org>
More information about the pkg-python-debian-discuss
mailing list