summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-01-12 17:01:34 +0100
committerJulian Andres Klode <jak@debian.org>2009-01-12 17:01:34 +0100
commit2e4443bbd9872f5599c9a8eb93a65d6c34c83ca2 (patch)
tree86e6f869f2f0e59f99df0f49f679dcd7eeba5255 /doc/examples
parenteb32fb89da3e3e1ff4a9668aaed6d533f04e9ee7 (diff)
downloadpython-apt-2e4443bbd9872f5599c9a8eb93a65d6c34c83ca2.tar.gz
Cleanup: Comparisons to True/False, ==/!= None, deprecated modules
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/action.py4
-rw-r--r--doc/examples/all_deps.py4
-rwxr-xr-xdoc/examples/build-deps.py3
-rw-r--r--doc/examples/depcache.py4
-rwxr-xr-xdoc/examples/dependant-pkgs.py2
-rwxr-xr-xdoc/examples/gui-inst.py9
-rw-r--r--doc/examples/progress.py9
-rwxr-xr-xdoc/examples/versiontest.py3
8 files changed, 14 insertions, 24 deletions
diff --git a/doc/examples/action.py b/doc/examples/action.py
index 7153292c..9b9d7dd3 100644
--- a/doc/examples/action.py
+++ b/doc/examples/action.py
@@ -86,7 +86,7 @@ print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
for pkg in cache.Packages:
- if pkg.CurrentVer != None and not depcache.MarkedInstall(pkg) \
+ if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \
and depcache.IsUpgradable(pkg):
print "Upgrade didn't upgrade (kept): %s" % pkg.Name
@@ -101,7 +101,7 @@ print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
# overview about what would happen
for pkg in cache.Packages:
if depcache.MarkedInstall(pkg):
- if pkg.CurrentVer != None:
+ if pkg.CurrentVer is not None:
print "Marked upgrade: %s " % pkg.Name
else:
print "Marked install: %s" % pkg.Name
diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py
index 0a2f3157..992e98d8 100644
--- a/doc/examples/all_deps.py
+++ b/doc/examples/all_deps.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
-
import sys
+
import apt
def dependencies(cache, pkg, deps, key="Depends"):
#print "pkg: %s (%s)" % (pkg.name, deps)
candver = cache._depcache.GetCandidateVer(pkg._pkg)
- if candver == None:
+ if candver is None:
return deps
dependslist = candver.DependsList
if key in dependslist:
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py
index dc1a6f4e..aeb5667c 100755
--- a/doc/examples/build-deps.py
+++ b/doc/examples/build-deps.py
@@ -3,7 +3,6 @@
import apt_pkg
import sys
-import sets # only needed for python2.3, python2.4 supports this naively
def get_source_pkg(pkg, records, depcache):
@@ -37,7 +36,7 @@ try:
except KeyError:
print "No package %s found" % sys.argv[1]
sys.exit(1)
-all_build_depends = sets.Set()
+all_build_depends = set()
# get the build depdends for the package itself
srcpkg_name = get_source_pkg(base, records, depcache)
diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py
index ad884fe7..790cc9d6 100644
--- a/doc/examples/depcache.py
+++ b/doc/examples/depcache.py
@@ -84,7 +84,7 @@ print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
for pkg in cache.Packages:
- if pkg.CurrentVer != None and not depcache.MarkedInstall(pkg) \
+ if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \
and depcache.IsUpgradable(pkg):
print "Upgrade didn't upgrade (kept): %s" % pkg.Name
@@ -100,7 +100,7 @@ print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
# overview about what would happen
for pkg in cache.Packages:
if depcache.MarkedInstall(pkg):
- if pkg.CurrentVer != None:
+ if pkg.CurrentVer is not None:
print "Marked upgrade: %s " % pkg.Name
else:
print "Marked install: %s" % pkg.Name
diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py
index bb10ce70..5fbbc76d 100755
--- a/doc/examples/dependant-pkgs.py
+++ b/doc/examples/dependant-pkgs.py
@@ -7,7 +7,7 @@ pkgs = set()
cache = apt.Cache()
for pkg in cache:
candver = cache._depcache.GetCandidateVer(pkg._pkg)
- if candver == None:
+ if candver is None:
continue
dependslist = candver.DependsList
for dep in dependslist.keys():
diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py
index cb49db3e..8138d922 100755
--- a/doc/examples/gui-inst.py
+++ b/doc/examples/gui-inst.py
@@ -1,20 +1,13 @@
#!/usr/bin/python
# example how to install in a custom terminal widget
# see also gnome bug: #169201
-
-import apt
-import apt_pkg
-import sys, os, fcntl
-import copy
-import string
-import fcntl
-
import pygtk
pygtk.require('2.0')
import gtk
import apt.gtk.widgets
+
if __name__ == "__main__":
win = gtk.Window()
diff --git a/doc/examples/progress.py b/doc/examples/progress.py
index c56734b7..83847598 100644
--- a/doc/examples/progress.py
+++ b/doc/examples/progress.py
@@ -1,8 +1,7 @@
-import apt
-from apt import SizeToStr
import sys
import time
-import string
+
+import apt
class TextProgress(apt.OpProgress):
@@ -39,8 +38,8 @@ class TextFetchProgress(apt.FetchProgress):
def pulse(self):
print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
- SizeToStr(self.currentCPS), SizeToStr(self.currentBytes),
- SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
+ apt.SizeToStr(self.currentCPS), SizeToStr(self.currentBytes),
+ apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
return True
def mediaChange(self, medium, drive):
diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py
index dd881f6b..fa13cc1c 100755
--- a/doc/examples/versiontest.py
+++ b/doc/examples/versiontest.py
@@ -4,7 +4,6 @@
import apt_pkg
import sys
import re
-import string
apt_pkg.InitConfig()
apt_pkg.InitSystem()
@@ -22,7 +21,7 @@ while(1):
CurLine = CurLine + 1
if Line == "":
break
- Line = string.strip(Line)
+ Line = Line.strip()
if len(Line) == 0 or Line[0] == '#':
continue