--- Begin Message ---
Package: python-apt
Version: 0.7.11.0
Severity: wishlist
Tags: patch
There are times when it would be nice to get the raw data for a tag,
without any white space stripped off the front. For example, see
#538376, where we would like to know if the data started with a newline.
I have attached a patch that adds a FindRaw method to TagSection. It
uses the C++ Find(char *Name, unsigned &Pos) method to get the position
of the tag in the section, then the Get method, to get the start and
stop of the tag. The result is the whole tag, not just the bits after
the colon with whitespace removed. For example:
>>> f = open('/tmp/apt_pkg.tmp', 'w')
>>> f.write("""\
... Package: foo
... Bar:
... Baz
... """)
>>> f.close()
>>> import apt_pkg; apt_pkg.init()
>>> parser = apt_pkg.ParseTagFile(open('/tmp/apt_pkg.tmp'))
>>> parser.Step()
1
>>> parser.Section.FindRaw('Package')
'Package: foo\n'
>>> parser.Section.FindRaw('Bar')
'Bar:\n Baz'
This way, I can write a wrapper around TagSection that handles leading
whitespace differently than the default implementation, e.g.:
class TagSectionWrapper(object, UserDict.DictMixin):
"""Wrap a TagSection object, using the FindRaw method instead of Find
This allows us to pick which whitespace to strip off the beginning and end
of the data, so we don't lose leading newlines.
"""
def __init__(self, parser):
self.parser = parser
def keys(self):
return self.parser.keys()
def __getitem__(self, key):
s = self.parser.FindRaw(key)
if s is None:
raise KeyError(key)
data = s.partition(':')[2]
# Get rid of spaces and tabs after the :, but not newlines, and strip
# off any newline at the end of the data.
return data.lstrip(' \t').rstrip('\n')
Thanks for considering the patch.
--
John Wright <jsw@debian.org>
--- End Message ---
--- Begin Message ---
Source: python-apt
Source-Version: 0.7.11.1
We believe that the bug you reported is fixed in the latest version of
python-apt, which is due to be installed in the Debian FTP archive:
python-apt-dbg_0.7.11.1_i386.deb
to pool/main/p/python-apt/python-apt-dbg_0.7.11.1_i386.deb
python-apt_0.7.11.1.dsc
to pool/main/p/python-apt/python-apt_0.7.11.1.dsc
python-apt_0.7.11.1.tar.gz
to pool/main/p/python-apt/python-apt_0.7.11.1.tar.gz
python-apt_0.7.11.1_i386.deb
to pool/main/p/python-apt/python-apt_0.7.11.1_i386.deb
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 538723@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Michael Vogt <mvo@debian.org> (supplier of updated python-apt package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.8
Date: Wed, 29 Jul 2009 19:15:56 +0200
Source: python-apt
Binary: python-apt python-apt-dbg
Architecture: source i386
Version: 0.7.11.1
Distribution: unstable
Urgency: low
Maintainer: APT Development Team <deity@lists.debian.org>
Changed-By: Michael Vogt <mvo@debian.org>
Description:
python-apt - Python interface to libapt-pkg
python-apt-dbg - Python interface to libapt-pkg (debug extension)
Closes: 538723
Changes:
python-apt (0.7.11.1) unstable; urgency=low
.
[ Stephan Peijnik ]
* apt/progress/__init__.py:
- Exception handling fixes in InstallProgress class.
.
[ Michael Vogt ]
* python/tag.cc:
- merge patch from John Wright that adds FindRaw method
(closes: #538723)
Checksums-Sha1:
8686a741ffbce2ab6c60ee2ab7abe8494454c730 1194 python-apt_0.7.11.1.dsc
2d6c40ad2b0c4a68bce65e336d8f59a8bbf6a2d8 677614 python-apt_0.7.11.1.tar.gz
f8d6abc4a3fcc893b5cdc391b472458fbd55cfd8 389250 python-apt_0.7.11.1_i386.deb
042db6e3fbd48c253ad563f315ff8e0033d77c48 1522192 python-apt-dbg_0.7.11.1_i386.deb
Checksums-Sha256:
d3564a52c02b6b433a021b5ba40d770c8691f2d8f47eb9731f5d7280710eae1e 1194 python-apt_0.7.11.1.dsc
a86b8bea86acae8cdd41fb36e20624323646c4ce0a02388d5cca547389d4ffb2 677614 python-apt_0.7.11.1.tar.gz
71ef144cfe8e9e7b61ef3e1f54762a24985e567bbe40d1f99923ad4ba9e8a981 389250 python-apt_0.7.11.1_i386.deb
fa944e8d59eee35cab91693039524b6f09faf38ca2a31ee858db6b6b538e0194 1522192 python-apt-dbg_0.7.11.1_i386.deb
Files:
b2e245f572de2cd1336de0b369e14e57 1194 python optional python-apt_0.7.11.1.dsc
d2c01743e795a45747eb2c62af09444f 677614 python optional python-apt_0.7.11.1.tar.gz
05604a8fe8eb0b23a648215d59e07e5b 389250 python optional python-apt_0.7.11.1_i386.deb
a4e396f810366af378cedcc17b866a6f 1522192 debug extra python-apt-dbg_0.7.11.1_i386.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkpwrQ8ACgkQliSD4VZixzSuLwCfcS6KhGYjAYU7TlFSZFDrFGRI
lboAoINkCbuxho/X6KdoAhUgub9o/glF
=u6ES
-----END PGP SIGNATURE-----
--- End Message ---