summaryrefslogtreecommitdiffstats
path: root/doc/examples/desc.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/examples/desc.py')
-rw-r--r--doc/examples/desc.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/examples/desc.py b/doc/examples/desc.py
new file mode 100644
index 0000000..7e8e3e8
--- /dev/null
+++ b/doc/examples/desc.py
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+
+import apt_pkg
+
+apt_pkg.init()
+
+apt_pkg.config.set("APT::Acquire::Translation", "de")
+
+cache = apt_pkg.Cache()
+depcache = apt_pkg.DepCache(cache)
+
+pkg = cache["gcc"]
+cand = depcache.get_candidate_ver(pkg)
+print(cand)
+
+desc = cand.TranslatedDescription
+print(desc)
+print(desc.file_list)
+(f, index) = desc.file_list.pop(0)
+
+records = apt_pkg.PackageRecords(cache)
+records.lookup((f, index))
+desc = records.long_desc
+print(len(desc))
+print(desc)