Bug#779217: python-apt-doc: [PATCH] Rewrite example using the new API
On Wed, Mar 04, 2015 at 07:06:18PM +0100, von wrote:
> Package: python-apt-doc
> Version: 0.9.3.11
> Followup-For: Bug #779217
>
> Here is a patch rewriting the print_uris.py example with the new API.
>
> This patch, as well as all contributions from matvon@mailoo.org, is under the GPL-2+ License.
Thanks a bunch! This is merged into git now and it will be part of the
next upload.
Cheers,
Michael
> -- System Information:
> Debian Release: 8.0
> APT prefers testing
> APT policy: (500, 'testing'), (400, 'unstable'), (300, 'experimental')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
>
> Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
>
> Versions of packages python-apt-doc depends on:
> ii libjs-jquery 1.7.2+dfsg-3.2
> ii libjs-sphinxdoc 1.2.3+dfsg-1
> ii libjs-underscore 1.7.0~dfsg-1
> ii python-apt 0.9.3.11
>
> python-apt-doc recommends no packages.
>
> python-apt-doc suggests no packages.
>
> -- no debconf information
> >From a9cbcf1e90e32971d370d97ae8d37d25fe0835f2 Mon Sep 17 00:00:00 2001
> From: von <matvon@mailoo.org>
> Date: Sat, 28 Feb 2015 17:00:04 +0100
> Subject: [PATCH] Update the print_uris.py example to use the new API
>
> ---
> doc/examples/print_uris.py | 18 +++---------------
> 1 file changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py
> index 06043e4..27e49d1 100755
> --- a/doc/examples/print_uris.py
> +++ b/doc/examples/print_uris.py
> @@ -4,19 +4,7 @@
> #
>
> import apt
> -import apt_pkg
>
> -
> -cache = apt.Cache()
> -upgradable = filter(lambda p: p.is_upgradable, cache)
> -
> -
> -for pkg in upgradable:
> - pkg._lookupRecord(True)
> - path = apt_pkg.TagSection(pkg._records.record)["Filename"]
> - cand = pkg._depcache.get_candidate_ver(pkg._pkg)
> - for (packagefile, i) in cand.file_list:
> - indexfile = cache._list.find_index(packagefile)
> - if indexfile:
> - uri = indexfile.archive_uri(path)
> - print uri
> +for pkg in apt.Cache():
> + if pkg.is_upgradable:
> + print pkg.candidate.uri
> --
> 2.1.4
>
Reply to: