Only parse one block from the debian changelog

authorJulien Cristau <julien.cristau@logilab.fr>
changeset8f203182838e
branchdefault
phasepublic
hiddenno
parent revision#68f6a41f1b78 Catch errors when parsing debian/changelog in parse_deb_project
child revision#5e695b561d98 lgp: fix string expansion in shell command when script are invoked (closes: #72414)
files modified by this revision
lgp/utils.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1312203539 -7200
# Mon Aug 01 14:58:59 2011 +0200
# Node ID 8f203182838ea440f5fc8113475a6ea77d38f63e
# Parent 68f6a41f1b7876c9fae79864964d3e558d3002c2
Only parse one block from the debian changelog

diff --git a/lgp/utils.py b/lgp/utils.py
@@ -218,11 +218,11 @@
1      return status, time.time() - t0
2 
3  def _parse_deb_distrib(changelog='debian/changelog'):
4      clog = Changelog()
5      try:
6 -        clog.parse_changelog(open(changelog))
7 +        clog.parse_changelog(open(changelog), max_blocks=1)
8          return clog.distributions
9      except IOError:
10          raise DistributionException("Debian changelog '%s' cannot be found" % changelog)
11      except ChangelogParseError:
12          raise DistributionException("Malformed Debian changelog '%s'" % changelog)
@@ -232,21 +232,21 @@
13                           in Deb822.iter_paragraphs(file(control))])
14 
15  def _parse_deb_version(changelog='debian/changelog'):
16      try:
17          clog = Changelog()
18 -        clog.parse_changelog(open(changelog))
19 +        clog.parse_changelog(open(changelog), max_blocks=1)
20          return clog.full_version
21      except IOError:
22          raise LGPException("Debian changelog '%s' cannot be found" % changelog)
23      except ChangelogParseError:
24          raise LGPException("Malformed Debian changelog '%s'" % changelog)
25 
26  def _parse_deb_project(changelog='debian/changelog'):
27      clog = Changelog()
28      try:
29 -        clog.parse_changelog(open(changelog))
30 +        clog.parse_changelog(open(changelog), max_blocks=1)
31          return clog.package
32      except ChangelogParseError:
33          raise LGPException("Malformed Debian changelog '%s'" % changelog)
34 
35  @contextmanager