Exemple #1
0
    def open(self, progress):
        """ Open the package cache, after that it can be used like
            a dictionary
        """
        self._runCallbacks("cache_pre_open")
        self._cache = apt_pkg.GetCache(progress)
        self._depcache = apt_pkg.GetDepCache(self._cache)
        self._records = apt_pkg.GetPkgRecords(self._cache)
        self._list = apt_pkg.GetPkgSourceList()
        self._list.ReadMainList()
        self._dict = {}

        # build the packages dict
        if progress != 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:
                progress.update(i / float(size) * 100)
                last = i
            # drop stuff with no versions (cruft)
            if len(pkg.VersionList) > 0:
                self._dict[pkg.Name] = Package(self._cache, self._depcache,
                                               self._records, self._list, self,
                                               pkg)

            i += 1
        if progress != None:
            progress.done()
        self._runCallbacks("cache_post_open")
Exemple #2
0
 def get_single_package(name):
     if type(package) != str:
         raise TypeError("Expected string")
     cache = apt_pkg.GetCache()
     depcache = apt_pkg.GetDepCache(cache)
     records = apt_pkg.GetPkgRecords(cache)
     sourcelist = apt_pkg.GetPkgSourceList()
     pkg = apt.package.Package(cache, depcache, records, sourcelist, None,
                               cache[sys.argv[1]])
     return pkg
Exemple #3
0
import apt_pkg

apt_pkg.init()

sources = apt_pkg.GetPkgSourceList()
sources.ReadMainList()


for metaindex in sources.List:
    print metaindex
    print "URI: ",metaindex.URI
    print "Dist: ",metaindex.Dist
    print "IndexFiles: ","\n".join([str(i) for i in metaindex.IndexFiles])
    print
Exemple #4
0
    def commit(self, fprogress, iprogress):
        """ commit the changes, need a FetchProgress and InstallProgress
            object as argument
        """
        self._depcache.Commit(fprogress, iprogress)


# self-test
if __name__ == "__main__":
    print "Self-test for the Package modul"
    apt_pkg.init()
    cache = apt_pkg.GetCache()
    depcache = apt_pkg.GetDepCache(cache)
    records = apt_pkg.GetPkgRecords(cache)
    sourcelist = apt_pkg.GetPkgSourceList()

    pkgiter = cache["apt-utils"]
    pkg = Package(cache, depcache, records, sourcelist, None, pkgiter)
    print "Name: %s " % pkg.name
    print "ID: %s " % pkg.id
    print "Priority (Candidate): %s " % pkg.priority
    print "Priority (Installed): %s " % pkg.installedPriority
    print "Installed: %s " % pkg.installedVersion
    print "Candidate: %s " % pkg.candidateVersion
    print "CandidateDownloadable: %s" % pkg.candidateDownloadable
    print "CandidateOrigins: %s" % pkg.candidateOrigin
    print "SourcePkg: %s " % pkg.sourcePackageName
    print "Section: %s " % pkg.section
    print "Summary: %s" % pkg.summary
    print "Description (formated) :\n%s" % pkg.description