From 513093cd51f95a8d014cd5436d3fff8556e10ced Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 10 Jan 2009 18:14:11 +0100 Subject: * doc/: Heavily improve documentation Complete the documentation of pkgCache, pkgDepCache, pkgCache::Package. Introduce new documentation for pkgCache::Version, pkgCache::Dependency, pkgCache::PackageFile, pkgcache::Description. There is also an example now which checks for missing dependencies. --- doc/source/examples/missing-deps.py | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 doc/source/examples/missing-deps.py (limited to 'doc/source/examples/missing-deps.py') diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py new file mode 100644 index 00000000..0870eb98 --- /dev/null +++ b/doc/source/examples/missing-deps.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +"""Check the archive for missing dependencies""" +import apt_pkg + + +def fmt_dep(dep): + """Format a Dependency object [of apt_pkg] as a string.""" + ret = dep.TargetPkg.Name + if dep.TargetVer: + ret += " (%s %s)" % (dep.CompType, dep.TargetVer) + return ret + +def check_version(pkgver): + """Check the version of the package""" + missing = [] + + for or_group in pkgver.DependsList.get("Pre-Depends", []) + \ + pkgver.DependsList.get("Depends", []): + if not any(dep.AllTargets() for dep in or_group): + # If none of the or-choices can be satisfied, add it to missing + missing.append(or_group) + + if missing: + print "Package:", pkgver.ParentPkg.Name + print "Version:", pkgver.VerStr + print "Missing:", + print ", ".join(" | ".join(fmt_dep(dep) for dep in or_group) + for or_group in missing) + print + + +def main(): + """The main function.""" + apt_pkg.InitConfig() + apt_pkg.InitSystem() + + cache = apt_pkg.GetCache() + + for pkg in sorted(cache.Packages, key=lambda pkg: pkg.Name): + # pkg is from a list of packages, sorted by name. + for version in pkg.VersionList: + # Check every version + for pfile, _ in version.FileList: + if (pfile.Origin == "Debian" and pfile.Component == "main" and + pfile.Archive == "unstable"): + # We only want packages from Debian unstable main. + check_version(version) + break + +if __name__ == "__main__": + main() -- cgit v1.2.3 From 2e4443bbd9872f5599c9a8eb93a65d6c34c83ca2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 12 Jan 2009 17:01:34 +0100 Subject: Cleanup: Comparisons to True/False, ==/!= None, deprecated modules --- apt/cache.py | 16 +++++------ aptsources/distinfo.py | 16 +++++------ aptsources/distro.py | 13 +++++---- aptsources/sourceslist.py | 54 +++++++++++++++++-------------------- doc/examples/action.py | 4 +-- doc/examples/all_deps.py | 4 +-- doc/examples/build-deps.py | 3 +-- doc/examples/depcache.py | 4 +-- doc/examples/dependant-pkgs.py | 2 +- doc/examples/gui-inst.py | 9 +------ doc/examples/progress.py | 9 +++---- doc/examples/versiontest.py | 3 +-- doc/source/conf.py | 18 +++++++------ doc/source/examples/missing-deps.py | 1 + setup.py | 9 +++---- tests/depcache.py | 2 +- tests/pkgproblemresolver.py | 2 +- tests/test_aptsources_ports.py | 18 ++++++++----- tests/test_debextract.py | 19 ++++++++----- 19 files changed, 98 insertions(+), 108 deletions(-) (limited to 'doc/source/examples/missing-deps.py') diff --git a/apt/cache.py b/apt/cache.py index f134ab0a..ff3149f5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -76,12 +76,12 @@ class Cache(object): self._dict = {} # build the packages dict - if progress != None: + if progress is not None: progress.Op = "Building data structures" i=last=0 size=len(self._cache.Packages) for pkg in self._cache.Packages: - if progress != None and last+100 < i: + if progress is not None and last+100 < i: progress.update(i/float(size)*100) last=i # drop stuff with no versions (cruft) @@ -91,7 +91,7 @@ class Cache(object): self, pkg) i += 1 - if progress != None: + if progress is not None: progress.done() self._runCallbacks("cache_post_open") @@ -216,7 +216,7 @@ class Cache(object): return providers for pkg in self: v = self._depcache.GetCandidateVer(pkg._pkg) - if v == None: + if v is None: continue for p in v.ProvidesList: if virtual == p[0]: @@ -232,7 +232,7 @@ class Cache(object): raise LockFailedException("Failed to lock %s" % lockfile) try: - if fetchProgress == None: + if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() return self._cache.Update(fetchProgress, self._list) finally: @@ -253,9 +253,9 @@ class Cache(object): # Current a failed download will just display "error" # which is less than optimal! - if fetchProgress == None: + if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() - if installProgress == None: + if installProgress is None: installProgress = apt.progress.InstallProgress() pm = apt_pkg.GetPackageManager(self._depcache) @@ -327,7 +327,7 @@ class FilteredCache(object): """ def __init__(self, cache=None, progress=None): - if cache == None: + if cache is None: self.cache = Cache(progress) else: self.cache = cache diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 3c499b52..59fa7e02 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -27,11 +27,9 @@ import os import gettext from os import getenv import ConfigParser -import string -import apt_pkg +import re -#from gettext import gettext as _ -import gettext +import apt_pkg def _(s): @@ -76,9 +74,9 @@ class Component: self.description_long = long_desc def get_description(self): - if self.description_long != None: + if self.description_long is not None: return self.description_long - elif self.description != None: + elif self.description is not None: return self.description else: return None @@ -221,8 +219,8 @@ class DistInfo: mirror_set = {} try: mirror_data = filter(match_mirror_line.match, - map(string.strip, open(value))) - except: + [x.strip() for x in open(value)]) + except Exception: print "WARNING: Failed to read mirror file" mirror_data = [] for line in mirror_data: @@ -256,7 +254,7 @@ class DistInfo: if not template: return # reuse some properties of the parent template - if template.match_uri == None and template.child: + if template.match_uri is None and template.child: for t in template.parents: if t.match_uri: template.match_uri = t.match_uri diff --git a/aptsources/distro.py b/aptsources/distro.py index a8f1d0fd..d8f191d6 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -21,7 +21,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import string import gettext import re import os @@ -86,7 +85,7 @@ class Distribution: # template.components self.source_template = template break - if self.source_template == None: + if self.source_template is None: raise NoDistroTemplateException("Error: could not find a " "distribution template") @@ -259,14 +258,14 @@ class Distribution: """ Add distribution specific sources """ - if uri == None: + if uri is None: # FIXME: Add support for the server selector uri = self.default_server - if dist == None: + if dist is None: dist = self.codename - if comps == None: + if comps is None: comps = list(self.enabled_comps) - if type == None: + if type is None: type = self.binary_type new_source = self.sourceslist.add(type, uri, dist, comps, comment) # if source code is enabled add a deb-src line after the new @@ -379,7 +378,7 @@ class Distribution: change_server_of_source(source, uri, seen_binary) for source in self.child_sources: # Do not change the forces server of a child source - if source.template.base_uri == None or \ + if source.template.base_uri is None or \ source.template.base_uri != source.uri: change_server_of_source(source, uri, seen_binary) for source in self.source_code_sources: diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index a0346267..dc2a5d45 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -23,18 +23,16 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import string import gettext -import re -import apt_pkg import glob -import shutil -import time import os.path +import re +import shutil import sys +import time -#from UpdateManager.Common.DistInfo import DistInfo -from distinfo import DistInfo +import apt_pkg +from aptsources.distinfo import DistInfo # some global helpers @@ -88,7 +86,7 @@ class SourceEntry: # (may empty) self.comment = "" # (optional) comment self.line = line # the original sources.list line - if file == None: + if file is None: file = apt_pkg.Config.FindDir( "Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist") self.file = file # the file that the entry is located in @@ -107,7 +105,7 @@ class SourceEntry: def mysplit(self, line): """ a split() implementation that understands the sources.list format better and takes [] into account (for e.g. cdroms) """ - line = string.strip(line) + line = line.strip() pieces = [] tmp = "" # we are inside a [..] block @@ -138,7 +136,7 @@ class SourceEntry: def parse(self, line): """ parse a given sources.list (textual) line and break it up into the field we have """ - line = string.strip(self.line) + line = self.line.strip() #print line # check if the source is enabled/disabled if line == "" or line == "#": # empty line @@ -146,7 +144,7 @@ class SourceEntry: return if line[0] == "#": self.disabled = True - pieces = string.split(line[1:]) + pieces = line[1:].strip() # if it looks not like a disabled deb line return if not pieces[0] in ("rpm", "rpm-src", "deb", "deb-src"): self.invalid = True @@ -165,18 +163,18 @@ class SourceEntry: self.invalid = True return # Type, deb or deb-src - self.type = string.strip(pieces[0]) + self.type = pieces[0].strip() # Sanity check if self.type not in ("deb", "deb-src", "rpm", "rpm-src"): self.invalid = True return # URI - self.uri = string.strip(pieces[1]) + self.uri = pieces[1].strip() if len(self.uri) < 1: self.invalid = True # distro and components (optional) # Directory or distro - self.dist = string.strip(pieces[2]) + self.dist = pieces[2].strip() if len(pieces) > 3: # List of components self.comps = pieces[3:] @@ -187,15 +185,11 @@ class SourceEntry: """ set a line to enabled or disabled """ self.disabled = not new_value # enable, remove all "#" from the start of the line - if new_value == True: - i=0 - self.line = string.lstrip(self.line) - while self.line[i] == "#": - i += 1 - self.line = self.line[i:] + if new_value: + self.line = self.line.lstrip().lstrip('#') else: # disabled, add a "#" - if string.strip(self.line)[0] != "#": + if self.line.strip()[0] != "#": self.line = "#" + self.line def __str__(self): @@ -251,7 +245,7 @@ class SourcesList: self.load(file) # check if the source item fits a predefined template for source in self.list: - if source.invalid == False: + if not source.invalid: self.matcher.match(source) def __iter__(self): @@ -272,7 +266,7 @@ class SourcesList: comps = orig_comps[:] # check if we have this source already in the sources.list for source in self.list: - if source.disabled == False and source.invalid == False and \ + if not source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist: for new_comp in comps: @@ -285,14 +279,14 @@ class SourcesList: for source in self.list: # if there is a repo with the same (type, uri, dist) just add the # components - if source.disabled == False and source.invalid == False and \ + if not source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist: comps = uniq(source.comps + comps) source.comps = comps return source # if there is a corresponding repo which is disabled, enable it - elif source.disabled == True and source.invalid == False and \ + elif source.disabled and not source.invalid and \ source.type == type and uri == source.uri and \ source.dist == dist and \ len(set(source.comps) & set(comps)) == len(comps): @@ -306,7 +300,7 @@ class SourcesList: line = "%s #%s\n" % (line, comment) line = line + "\n" new_entry = SourceEntry(line) - if file != None: + if file is not None: new_entry.file = file self.matcher.match(new_entry) self.list.insert(pos, new_entry) @@ -333,7 +327,7 @@ class SourcesList: """ make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned) """ already_backuped = set() - if backup_ext == None: + if backup_ext is None: backup_ext = time.strftime("%y%m%d.%H%M") for source in self.list: if not source.file in already_backuped \ @@ -380,11 +374,11 @@ class SourcesList: used_child_templates = {} for source in sources_list: # try to avoid checking uninterressting sources - if source.template == None: + if source.template is None: continue # set up a dict with all used child templates and corresponding # source entries - if source.template.child == True: + if source.template.child: key = source.template if key not in used_child_templates: used_child_templates[key] = [] @@ -414,7 +408,7 @@ class SourceEntryMatcher: f = f[0:i] dist = DistInfo(f, base_dir=matcherPath) for template in dist.templates: - if template.match_uri != None: + if template.match_uri is not None: self.templates.append(template) return 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 diff --git a/doc/source/conf.py b/doc/source/conf.py index bb8056ad..8f71e3e3 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -3,18 +3,20 @@ # python-apt documentation build configuration file, created by # sphinx-quickstart on Wed Jan 7 17:04:36 2009. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # The contents of this file are pickled, so don't put values in the namespace -# that aren't pickleable (module imports are okay, they're removed automatically). +# that aren't pickleable (module imports are okay, they're removed +# automatically). # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. - -import sys, os +import os +import sys # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it @@ -28,8 +30,8 @@ if os.path.exists("../../build"): # General configuration # --------------------- -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo'] intersphinx_mapping = {'http://docs.python.org/': None} @@ -76,7 +78,7 @@ release = '0.7.9~exp2' # for source files. exclude_trees = [] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -172,7 +174,7 @@ htmlhelp_basename = 'python-aptdoc' #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, document class [howto/manual]). +# (source index, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'python-apt.tex', ur'python-apt Documentation', ur'Julian Andres Klode ', 'manual'), diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py index 0870eb98..3ca16e45 100644 --- a/doc/source/examples/missing-deps.py +++ b/doc/source/examples/missing-deps.py @@ -10,6 +10,7 @@ def fmt_dep(dep): ret += " (%s %s)" % (dep.CompType, dep.TargetVer) return ret + def check_version(pkgver): """Check the version of the package""" missing = [] diff --git a/setup.py b/setup.py index c9f940a4..6a22734d 100755 --- a/setup.py +++ b/setup.py @@ -3,24 +3,21 @@ from distutils.core import setup, Extension from distutils.sysconfig import parse_makefile -from DistUtilsExtra.command import * +from DistUtilsExtra.command import build_extra, build_i18n import glob import os -import os.path -import pydoc import shutil -import string import sys # The apt_pkg module files = map(lambda source: "python/"+source, - string.split(parse_makefile("python/makefile")["APT_PKG_SRC"])) + parse_makefile("python/makefile")["APT_PKG_SRC"].split()) apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module files = map(lambda source: "python/"+source, - string.split(parse_makefile("python/makefile")["APT_INST_SRC"])) + parse_makefile("python/makefile")["APT_INST_SRC"].split()) apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation diff --git a/tests/depcache.py b/tests/depcache.py index b199c812..19aba680 100644 --- a/tests/depcache.py +++ b/tests/depcache.py @@ -22,7 +22,7 @@ def main(): x = pkg.Name # then get each version ver =depcache.GetCandidateVer(pkg) - if ver != None: + if ver is not None: depcache.MarkInstall(pkg) if depcache.InstCount == 0: if depcache.IsUpgradable(pkg): diff --git a/tests/pkgproblemresolver.py b/tests/pkgproblemresolver.py index 7d5ae682..a21d8d9d 100644 --- a/tests/pkgproblemresolver.py +++ b/tests/pkgproblemresolver.py @@ -22,7 +22,7 @@ def main(): x = pkg.Name # then get each version ver =depcache.GetCandidateVer(pkg) - if ver != None: + if ver is not None: depcache.MarkInstall(pkg) if depcache.BrokenCount > 0: fixer = apt_pkg.GetPkgProblemResolver(depcache) diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py index 203721c7..09d6e9d9 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -1,28 +1,32 @@ #!/usr/bin/env python import unittest -import apt_pkg + import os import copy - import sys + sys.path.insert(0, "../") +import apt_pkg import aptsources import aptsources.sourceslist import aptsources.distro + class TestAptSources(unittest.TestCase): + def __init__(self, methodName): unittest.TestCase.__init__(self, methodName) apt_pkg.init() - apt_pkg.Config.Set("APT::Architecture","powerpc") - apt_pkg.Config.Set("Dir::Etc", os.path.join(os.getcwd(),"test-data-ports")) - apt_pkg.Config.Set("Dir::Etc::sourceparts","/xxx") + apt_pkg.Config.Set("APT::Architecture", "powerpc") + apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports")) + apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist","sources.list") + apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro("Ubuntu","hardy","desc","8.04") + distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", + "8.04") distro.get_sources(sources) # test if all suits of the current distro were detected correctly dist_templates = set() diff --git a/tests/test_debextract.py b/tests/test_debextract.py index c080b26e..4ba498ae 100755 --- a/tests/test_debextract.py +++ b/tests/test_debextract.py @@ -1,13 +1,18 @@ #!/usr/bin/python +import sys import apt_inst -import sys -def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor): + +def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( - What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor) + What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) + + +def main(): + member = "data.tar.lzma" + if len(sys.argv) > 2: + member = sys.argv[2] + apt_inst.debExtract(open(sys.argv[1]), Callback, member) -member = "data.tar.lzma" -if len(sys.argv) > 2: - member = sys.argv[2] -apt_inst.debExtract(open(sys.argv[1]), Callback, member) +main() -- cgit v1.2.3