summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-06-09 17:38:18 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-06-09 17:38:18 +0200
commit0bb531dbcf27b40861467b831b120fc8b257e8ff (patch)
treebbbda3be325306bbbe56b22aca25984bee710ddb /doc
parent52ae9a181314398e4dc4996d1409e99b9bdbbf7e (diff)
downloadpython-apt-0bb531dbcf27b40861467b831b120fc8b257e8ff.tar.gz
* changelog updated
* prints_uris.py example added
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/examples/print_uris.py22
-rw-r--r--doc/examples/sources.py2
2 files changed, 23 insertions, 1 deletions
diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py
new file mode 100755
index 00000000..c8a64223
--- /dev/null
+++ b/doc/examples/print_uris.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+#
+# a example that prints the URIs of all upgradable packages
+#
+
+import apt
+import apt_pkg
+
+
+cache = apt.Cache()
+upgradable = filter(lambda p: p.isUpgradable, cache)
+
+
+for pkg in upgradable:
+ pkg._lookupRecord(True)
+ path = apt_pkg.ParseSection(pkg._records.Record)["Filename"]
+ cand = pkg._depcache.GetCandidateVer(pkg._pkg)
+ for (packagefile,i) in cand.FileList:
+ indexfile = cache._list.FindIndex(packagefile)
+ if indexfile:
+ uri = indexfile.ArchiveURI(path)
+ print uri
diff --git a/doc/examples/sources.py b/doc/examples/sources.py
index 78913523..c12c6f15 100644
--- a/doc/examples/sources.py
+++ b/doc/examples/sources.py
@@ -11,5 +11,5 @@ sources = apt_pkg.GetPkgSrcRecords()
sources.Restart()
while sources.Lookup('hello'):
print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries`
- #print sources.Files
+ print sources.Files
print sources.Index.ArchiveURI("")