From 6a806f0570599e8f5e9438c9623d496df75571d4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 9 Jan 2009 21:52:07 +0100 Subject: * Introduce the new documentation and add 0.7.9~exp2 to changelog. The new documentation is built using sphinx (>= 0.5) [other versions may work too, but let's be safe]. --- doc/source/examples/apt-gtk.py | 29 +++++++++++++++++++ doc/source/examples/dpkg-contents.py | 55 ++++++++++++++++++++++++++++++++++++ doc/source/examples/dpkg-extract.py | 25 ++++++++++++++++ doc/source/examples/dpkg-info.py | 20 +++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 doc/source/examples/apt-gtk.py create mode 100644 doc/source/examples/dpkg-contents.py create mode 100644 doc/source/examples/dpkg-extract.py create mode 100644 doc/source/examples/dpkg-info.py (limited to 'doc/source/examples') diff --git a/doc/source/examples/apt-gtk.py b/doc/source/examples/apt-gtk.py new file mode 100644 index 00000000..c3bb09d5 --- /dev/null +++ b/doc/source/examples/apt-gtk.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +"""Example for gtk widgets""" +import pygtk +pygtk.require("2.0") +import gtk + +import apt.gtk.widgets + + +def main(): + """Main function.""" + win = gtk.Window() + win.connect("destroy", gtk.main_quit) + progress = apt.gtk.widgets.GtkAptProgress() + win.set_title("GtkAptProgress Demo") + win.add(progress) + progress.show() + win.show() + cache = apt.cache.Cache(progress.open) + if cache["xterm"].isInstalled: + cache["xterm"].markDelete() + else: + cache["xterm"].markInstall() + progress.show_terminal(expanded=True) + cache.commit(progress.fetch, progress.install) + gtk.main() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-contents.py b/doc/source/examples/dpkg-contents.py new file mode 100644 index 00000000..99d1596f --- /dev/null +++ b/doc/source/examples/dpkg-contents.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +"""Emulate dpkg --contents""" + +import grp +import pwd +import stat +import sys +import time + +import apt_inst + + +def format_mode(what, mode): + """Return the symbolic mode""" + s_mode = dict(DIR="d", HARDLINK="h", FILE="-").get(what) + s_mode += ((mode & stat.S_IRUSR) and "r" or "-") + s_mode += ((mode & stat.S_IWUSR) and "w" or "-") + s_mode += ((mode & stat.S_IXUSR) and (mode & stat.S_ISUID and "s" or "x") + or (mode & stat.S_ISUID and "S" or "-")) + s_mode += ((mode & stat.S_IRGRP) and "r" or "-") + s_mode += ((mode & stat.S_IWGRP) and "w" or "-") + s_mode += ((mode & stat.S_IXGRP) and (mode & stat.S_ISGID and "s" or "x") + or (mode & stat.S_ISGID and "S" or "-")) + s_mode += ((mode & stat.S_IROTH) and "r" or "-") + s_mode += ((mode & stat.S_IWOTH) and "w" or "-") + s_mode += ((mode & stat.S_IXOTH) and "x" or "-") + return s_mode + + +def callback(what, name, link, mode, uid, gid, size, mtime, major, minor): + """callback for debExtract""" + s_mode = format_mode(what, mode) + s_owner = "%s/%s" % (pwd.getpwuid(uid)[0], grp.getgrgid(gid)[0]) + s_size = "%9d" % size + s_time = time.strftime("%Y-%m-%d %H:%M", time.localtime(mtime)) + s_name = name.startswith(".") and name or ("./" + name) + if link: + s_name += " link to %s" % link + print s_mode, s_owner, s_size, s_time, s_name + + +def main(): + """Main function""" + if len(sys.argv) < 2: + print >> sys.stderr, "need filename argumnet" + sys.exit(1) + + fobj = open(sys.argv[1]) + try: + apt_inst.debExtract(fobj, callback, "data.tar.gz") + finally: + fobj.close() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-extract.py b/doc/source/examples/dpkg-extract.py new file mode 100644 index 00000000..ced8652f --- /dev/null +++ b/doc/source/examples/dpkg-extract.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +"""Emulate dpkg --extract package.deb outdir""" +import os +import sys + +import apt_inst + + +def main(): + """Main function.""" + if len(sys.argv) < 3: + print >> sys.stderr, "Usage:", __file__, "package.deb outdir" + sys.exit(1) + if not os.path.exists(sys.argv[2]): + print >> sys.stderr, "The directory %s does not exist" % sys.argv[2] + sys.exit(1) + + fobj = open(sys.argv[1]) + try: + apt_inst.debExtractArchive(fobj, sys.argv[2]) + finally: + fobj.close() + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/dpkg-info.py b/doc/source/examples/dpkg-info.py new file mode 100644 index 00000000..ff98d8b1 --- /dev/null +++ b/doc/source/examples/dpkg-info.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +"""Emulate dpkg --info package.deb control-file""" +import sys + +from apt_inst import debExtractControl + + +def main(): + """Main function.""" + if len(sys.argv) < 3: + print >> sys.stderr, 'Usage: tool file.deb control-file' + sys.exit(0) + fobj = open(sys.argv[1]) + try: + print debExtractControl(fobj, sys.argv[2]) + finally: + fobj.close() + +if __name__ == '__main__': + main() -- cgit v1.2.3 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/apt/debfile.rst | 6 +- doc/source/apt_pkg/cache.rst | 532 +++++++++++++++++++++++++++++++++- doc/source/apt_pkg/index.rst | 24 +- doc/source/conf.py | 5 +- doc/source/examples/cache-packages.py | 22 ++ doc/source/examples/cache-pkgfile.py | 29 ++ doc/source/examples/missing-deps.py | 51 ++++ 7 files changed, 655 insertions(+), 14 deletions(-) create mode 100644 doc/source/examples/cache-packages.py create mode 100644 doc/source/examples/cache-pkgfile.py create mode 100644 doc/source/examples/missing-deps.py (limited to 'doc/source/examples') diff --git a/doc/source/apt/debfile.rst b/doc/source/apt/debfile.rst index 70c39087..c0146df9 100644 --- a/doc/source/apt/debfile.rst +++ b/doc/source/apt/debfile.rst @@ -21,8 +21,10 @@ Binary packages If you specify ``cache`` it has to point to an :class:`apt.cache.Cache()` object. - All methods except for :meth:`open()` and the attribute :attr:`filelist` have been - introduced in version 0.7.9. + .. versionchanged:: 0.7.9 + Introduce all new methods (everything except for :meth:`open()` and + :attr:`filelist`) + Source packages ---------------- diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index abb0fab2..81ee2a8e 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -1,5 +1,10 @@ -Low-Level Cache Handling -=========================== +Classes in apt_pkg +================== + +.. todo:: + + This should be split and cleaned up a bit. + .. class:: Acquire @@ -12,6 +17,9 @@ Low-Level Cache Handling Shut the fetcher down. + +The cache +--------- .. class:: pkgCache The :class:`pkgCache` class prov @@ -37,10 +45,121 @@ Low-Level Cache Handling .. method:: __getitem__(item) - Return an :class:`pkgCachePackage` object for the package with the given + Return an :class:`Package` object for the package with the given name. -.. class:: pkgCachePackage + .. attribute:: DependsCount + + The total number of dependencies. + + .. attribute:: PackageCount + + The total number of packages available in the cache. + + .. attribute:: ProvidesCount + + The number of provided packages. + + .. attribute:: VerFileCount + + .. todo:: Seems to be some mixture of versions and pkgFile. + + .. attribute:: VersionCount + + The total number of package versions available in the cache. + + .. attribute:: PackageFileCount + + The total number of Packages files available (the Packages files + listing the packages). This is the same as the length of the list in + the attribute :attr:`FileList`. + + .. attribute:: FileList + + A list of :class:`PackageFile` objects. + + +PackageFile +------------ +.. class:: PackageFile + + A :class:`PackageFile` represents a Packages file, eg. + /var/lib/dpkg/status. + + .. attribute:: Architecture + + The architecture of the package file. + + .. attribute:: Archive + + The archive (eg. unstable) + + .. attribute:: Component + + The component (eg. main) + + .. attribute:: FileName + + The name of the file. + + .. attribute:: ID + + The ID of the package. This is an integer which can be used to store + further information about the file [eg. as dictionary key]. + + .. attribute:: IndexType + + The sort of the index file. In normal cases, this is + 'Debian Package Index'. + + .. attribute:: Label + + The Label, as set in the Release file + + .. attribute:: NotAutomatic + + Whether packages from this list will be updated automatically. The + default for eg. example is 0 (aka false). + + .. attribute:: NotSource + + Whether the file has no source from which it can be updated. In such a + case, the value is 1; else 0. /var/lib/dpkg/status is 0 for example. + + Example: + + .. code-block:: python + + for pkgfile in cache.FileList: + if pkgfile.NotSource: + print 'The file %s has no source.' % pkgfile.FileName + + .. attribute:: Origin + + The Origin, as set in the Release file + + .. attribute:: Site + + The hostname of the site. + + .. attribute:: Size + + The size of the file. + + .. attribute:: Version + + The version, as set in the release file (eg. "4.0" for "Etch") + + +Example +^^^^^^^ +.. literalinclude:: ../examples/cache-pkgfile.py + + +A Package +--------- + +.. class:: Package The pkgCache::Package objects are an interface to package specific features. @@ -48,23 +167,285 @@ Low-Level Cache Handling Attributes: + .. attribute:: CurrentVer + + The version currently installed, or None. This returns a + :class:`Version` object. + + .. attribute:: ID + + The ID of the package. This can be used to store information about + the package. The ID is an int value. + .. attribute:: Name This is the name of the package. + .. attribute:: ProvidesList + + A list of packages providing this package. More detailed, this is a + list of tuples (str:pkgname, ????, :class:`Version`). + + If you want to check for check for virtual packages, the expression + ``pkg.ProvidesList and not pkg.VersionList`` helps you. It detects if + the package is provided by something else and is not available as a + real package. + + .. attribute:: RevDependsList + + An iterator of :class:`Dependency` objects for dependencies on this + package. + .. attribute:: Section The section of the package, as specified in the record. The list of possible sections is defined in the Policy. + .. attribute:: VersionList + + A list of :class:`Version` objects for all versions available in the + cache. + + **States**: + + .. attribute:: SelectedState + + The state we want it to be, ie. if you mark a package for installation, + this is :attr:`apt_pkg.SelStateInstall`. + + See :ref:`SelStates` for a list of available states. + + .. attribute:: InstState + + The state the currently installed version is in. This is normally + :attr:`apt_pkg.InstStateOK`, unless the installation failed. + + See :ref:`InstStates` for a list of available states. + + .. attribute:: CurState + + The current state of the package (not installed, unpacked, installed, + etc). See :ref:`CurStates` for a list of available states. + + **Flags**: + + .. attribute:: Auto + + Whether the package was installed automatically as a dependency of + another package. (or marked otherwise as automatically installed) + + .. attribute:: Essential + + Whether the package is essential. + + .. attribute:: Important + + Whether the package is important. + +Example: +^^^^^^^^^ +.. literalinclude:: ../examples/cache-packages.py + + + +Version, as returned by eg. :meth:`pkgDepCache.GetCandidateVer` +--------------------------------------------------------------- +.. class:: Version + + The version object contains all information related to a specific package + version. + + .. attribute:: VerStr + + The version, as a string. + + .. attribute:: Section + + The usual sections (eg. admin, net, etc.). Prefixed with the component + name for packages not in main (eg. non-free/admin). + + .. attribute:: Arch + + The architecture of the package, eg. amd64 or all. + + .. attribute:: FileList + + A list of (:class:`PackageFile`, int: index) tuples for all Package + files containing this version of the package. + + .. attribute:: DependsListStr + + A dictionary of dependencies. The key specifies the type of the + dependency ('Depends', 'Recommends', etc.). + + + The value is a list, containing items which refer to the or-groups of + dependencies. Each of these or-groups is itself a list, containing + tuples like ('pkgname', 'version', 'relation') for each or-choice. + + An example return value for a package with a 'Depends: python (>= 2.4)' + would be: + + .. code-block:: python + + {'Depends': [ + [ + ('python', '2.4', '>=') + ] + ] + } + + The same for a dependency on A (>= 1) | B (>= 2): + + .. code-block:: python + + {'Depends': [ + [ + ('A', '1', '>='), + ('B', '2', '>='), + ] + ] + } + + .. attribute:: DependsList + + This is basically the same as :attr:`Version.DependsListStr`, + but instead of the ('pkgname', 'version', 'relation') tuples, + it returns :class:`Dependency` objects, which can assist you with + useful functions. + + .. attribute:: ParentPkg + + The :class:`Package` object this version belongs to. + + .. attribute:: ProvidesList + + This returns a list of all packages provided by this version. Like + :attr:`Package.ProvidesList`, it returns a list of tuples + of the form ('virtualpkgname', ???, :class:`Version`), where as the + last item is the same as the object itself. + + .. attribute:: Size + + The size of the .deb file, in bytes. + + .. attribute:: InstalledSize + + The size of the package (in kilobytes), when unpacked on the disk. + + .. attribute:: Hash + + An integer hash value. + .. attribute:: ID - The ID of the package. This can be used to store information about - the package. The ID is an int value. + An integer id. + + .. attribute:: Priority + + The integer representation of the priority. This can be used to speed + up comparisons a lot, compared to :attr:`Version.PriorityStr`. + + The values are defined in the :mod:`apt_pkg` extension, see + :ref:`Priorities` for more information. + + .. attribute:: PriorityStr + + Return the priority of the package version, as a string, eg. + "optional". + + .. attribute:: Downloadable + + Whether this package can be downloaded from a remote site. + + .. attribute:: TranslatedDescription + + Return a :class:`Description` object. + + +The Dependency class +-------------------- +.. class:: Dependency + + Represent a dependency from one package to another one. + + .. method:: AllTargets + + A list of :class:`Version` objects which satisfy the dependency, + and do not conflict with already installed ones. + + From my experience, if you use this method to select the target + version, it is the best to select the last item unless any of the + other candidates is already installed. This leads to results being + very close to the normal package installation. + + .. method:: SmartTargetPkg + + Return a :class:`Version` object of a package which satisfies the + dependency and does not conflict with installed packages + (the 'natural target'). + + .. attribute:: TargetVer + + The target version of the dependency, as string. Empty string if the + dependency is not versioned. + .. attribute:: TargetPkg -Working with dependencies -------------------------- + The :class:`Package` object of the target package. + + .. attribute:: ParentVer + + The :class:`Version` object of the parent version, ie. the package + which declares the dependency. + + .. attribute:: ParentPkg + + The :class:`Package` object of the package which declares the + dependency. This is the same as using ParentVer.ParentPkg. + + .. attribute:: CompType + + The type of comparison (>=, ==, >>, <=), as string. + + .. attribute:: DepType + + The type of the dependency, as string, eg. "Depends". + + .. attribute:: ID + + The ID of the package, as integer. + +Example: Find all missing dependencies +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +With the help of Dependency.AllTargets(), you can easily find all packages with +broken dependencies: + +.. literalinclude:: ../examples/missing-deps.py + + +The Description class +--------------------- +.. class:: Description + + Represent the description of the package. + + .. attribute:: LanguageCode + + The language code of the description + + .. attribute:: md5 + + The md5 hashsum of the description + + .. attribute:: FileList + + A list of tuples (:class:`PackageFile`, int: index). + + + +The pkgDepCache wrapper +----------------------- .. class:: pkgDepCache The pkgDepCache object contains various methods to manipulate the cache, @@ -89,7 +470,138 @@ Working with dependencies Return the candidate version of the package, ie. the version that would be installed normally. - The parameter ``pkg`` refers to an :class:`pkgCachePackage` object, + The parameter ``pkg`` refers to an :class:`Package` object, available using the :class:`pkgCache`. - This method returns a :class:`pkgCacheVersion` object. + This method returns a :class:`Version` object. + + .. method:: SetCandidateVer(pkg, version) + + The opposite of :meth:`pkgDepCache.GetCandidateVer`. Set the candidate + version of the :class:`Package` ``pkg`` to the :class:`Version` + ``version``. + + + .. method:: Upgrade([distUpgrade=False]) + + Perform an upgrade. More detailed, this marks all the upgradable + packages for upgrade. You still need to call + :meth:`pkgDepCache.Commit` for the changes to apply. + + To perform a dist-upgrade, the optional parameter ``distUpgrade`` has + to be set to True. + + .. method:: FixBroken() + + Fix broken packages. + + .. method:: ReadPinFile() + + Read the policy, eg. /etc/apt/preferences. + + .. method:: MinimizeUpgrade() + + Go over the entire set of packages and try to keep each package marked + for upgrade. If a conflict is generated then the package is restored. + + .. todo:: + Explain better.. + + .. method:: MarkKeep(pkg) + + Mark the :class:`Package` ``pkg`` for keep. + + .. method:: MarkDelete(pkg[, purge]) + + Mark the :class:`Package` ``pkg`` for delete. If ``purge`` is True, + the configuration files will be removed as well. + + .. method:: MarkInstall(pkg[, autoInst=True[, fromUser=True]]) + + Mark the :class:`Package` ``pkg`` for install. + + If ``autoInst`` is True, the dependencies of the package will be + installed as well. This is the default. + + If ``fromUser`` is True, the package will be marked as manually + installed. This is the default. + + .. method:: SetReinstall(pkg) + + Set if the :class:`Package` ``pkg`` should be reinstalled. + + .. method:: IsUpgradable(pkg) + + Return `1` if the package is upgradable. + + The package can be upgraded by calling :meth:`pkgDepCache.MarkInstall`. + + .. method:: IsNowBroken(pkg) + + Return `1` if the package is broken now (including changes made, but + not committed). + + .. method:: IsInstBroken(pkg) + + Return `1` if the package is broken on the current install. This takes + changes which have not been committed not into effect. + + .. method:: IsGarbage(pkg) + + Return `1` if the package is garbage, ie. if it is automatically + installed and no longer referenced by other packages. + + .. method:: IsAutoInstalled(pkg) + + Return `1` if the package is automatically installed (eg. as the + dependency of another package). + + .. method:: MarkedInstall(pkg) + + Return `1` if the package is marked for install. + + .. method:: MarkedUpgrade(pkg) + + Return `1` if the package is marked for upgrade. + + .. method:: MarkedDelete(pkg) + + Return `1` if the package is marked for delete. + + .. method:: MarkedKeep(pkg) + + Return `1` if the package is marked for keep. + + .. method:: MarkedReinstall(pkg) + + Return `1` if the package should be installed. + + .. method:: MarkedDowngrade(pkg) + + Return `1` if the package should be downgraded. + + .. attribute:: KeepCount + + Integer, number of packages marked as keep + + .. attribute:: InstCount + + Integer, number of packages marked for installation. + + .. attribute:: DelCount + + Number of packages which should be removed. + + .. attribute:: BrokenCount + + Number of packages which are broken. + + .. attribute:: UsrSize + + The size required for the changes on the filesystem. If you install + packages, this is positive, if you remove them its negative. + + .. attribute:: DebSize + + The size of the packages which are needed for the changes to be + applied. diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index 5f23df31..1c5866a9 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -83,6 +83,20 @@ The Acquire interface Shut the fetcher down. + .. attribute:: Acquire.TotalNeeded + + The total amount of bytes needed (including those of files which are + already present) + + .. attribute:: Acquire.FetchNeeded + + The total amount of bytes which need to be fetched. + + .. attribute:: Acquire.PartialPresent + + Whether some files have been acquired already. (???) + + .. function:: GetPkgAcqFile(aquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) The parameter ``acquire`` refers to an :class:`Acquire()` object as returned @@ -184,6 +198,8 @@ Data .. data:: RewriteSourceOrder +.. _CurStates: + Package States ^^^^^^^^^^^^^^^ .. data:: CurStateConfigFiles @@ -206,6 +222,8 @@ Dependency types .. data:: DepReplaces .. data:: DepSuggests +.. _InstStates: + Installed states ^^^^^^^^^^^^^^^^^ .. data:: InstStateHold @@ -213,6 +231,7 @@ Installed states .. data:: InstStateOk .. data:: InstStateReInstReq +.. _Priorities: Priorities ^^^^^^^^^^ @@ -222,7 +241,10 @@ Priorities .. data:: PriRequired .. data:: PriStandard -Dselect states + +.. _SelStates: + +Select states ^^^^^^^^^^^^^^ .. data:: SelStateDeInstall .. data:: SelStateHold diff --git a/doc/source/conf.py b/doc/source/conf.py index 907e2275..bb8056ad 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -30,7 +30,8 @@ if os.path.exists("../../build"): # 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'] +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', 'sphinx.ext.todo'] intersphinx_mapping = {'http://docs.python.org/': None} # Add any paths that contain templates here, relative to this directory. @@ -193,3 +194,5 @@ latex_documents = [ # If false, no module index is generated. #latex_use_modindex = True + +todo_include_todos = True diff --git a/doc/source/examples/cache-packages.py b/doc/source/examples/cache-packages.py new file mode 100644 index 00000000..1abe7cf2 --- /dev/null +++ b/doc/source/examples/cache-packages.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +"""Example for packages. Print all essential and important packages""" + +import apt_pkg + + +def main(): + """Main.""" + apt_pkg.InitConfig() + apt_pkg.InitSystem() + cache = apt_pkg.GetCache() + print "Essential packages:" + for pkg in cache.Packages: + if pkg.Essential: + print " ", pkg.Name + print "Important packages:" + for pkg in cache.Packages: + if pkg.Important: + print " ", pkg.Name + +if __name__ == "__main__": + main() diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py new file mode 100644 index 00000000..f25975d3 --- /dev/null +++ b/doc/source/examples/cache-pkgfile.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +import apt_pkg + + +def main(): + """Example for PackageFile()""" + apt_pkg.init() + cache = apt_pkg.GetCache() + for pkgfile in cache.FileList: + print 'Package-File:', pkgfile.FileName + print 'Index-Type:', pkgfile.IndexType # 'Debian Package Index' + if pkgfile.NotSource: + 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.NotAutomatic: + # The system won't be updated automatically (eg. experimental) + print 'Automatic: No' + else: + print 'Automatic: Yes' + print + +if __name__ == '__main__': + main() 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') 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