summaryrefslogtreecommitdiffstats
path: root/doc/source/examples/cache-pkgfile.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
commit76926159194e180003aa78de97e5f287bf4325a5 (patch)
tree2cea7245cdc3f66355900c820c145eba90598766 /doc/source/examples/cache-pkgfile.py
parentInitial commit. (diff)
downloadpython-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz
python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xdoc/source/examples/cache-pkgfile.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py
new file mode 100755
index 0000000..4e94a7a
--- /dev/null
+++ b/doc/source/examples/cache-pkgfile.py
@@ -0,0 +1,30 @@
+#!/usr/bin/python3
+import apt_pkg
+
+
+def main():
+ """Example for PackageFile()"""
+ apt_pkg.init()
+ cache = apt_pkg.Cache()
+ for pkgfile in cache.file_list:
+ print("Package-File:", pkgfile.filename)
+ print("Index-Type:", pkgfile.index_type) # 'Debian Package Index'
+ if pkgfile.not_source:
+ print("Source: None")
+ else:
+ if pkgfile.site:
+ # There is a source, and a site, print the site
+ print("Source:", pkgfile.site)
+ else:
+ # It seems to be a local repository
+ print("Source: Local package file")
+ if pkgfile.not_automatic:
+ # The system won't be updated automatically (eg. experimental)
+ print("Automatic: No")
+ else:
+ print("Automatic: Yes")
+ print()
+
+
+if __name__ == "__main__":
+ main()