Commit d19943ea authored by Julian Andres Klode's avatar Julian Andres Klode

* Update the code to use the new classes.

parent a7026989
......@@ -78,10 +78,10 @@ class Cache(object):
if progress is None:
progress = apt.progress.OpProgress()
self._run_callbacks("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._cache = apt_pkg.Cache(progress)
self._depcache = apt_pkg.DepCache(self._cache)
self._records = apt_pkg.PackageRecords(self._cache)
self._list = apt_pkg.SourceList()
self._list.ReadMainList()
self._set = set()
self._weakref = weakref.WeakValueDictionary()
......@@ -154,8 +154,8 @@ class Cache(object):
@property
def required_download(self):
"""Get the size of the packages that are required to download."""
pm = apt_pkg.GetPackageManager(self._depcache)
fetcher = apt_pkg.GetAcquire()
pm = apt_pkg.PackageManager(self._depcache)
fetcher = apt_pkg.Acquire()
pm.GetArchives(fetcher, self._list, self._records)
return fetcher.FetchNeeded
......@@ -270,7 +270,7 @@ class Cache(object):
def install_archives(self, pm, install_progress):
"""
The first parameter *pm* refers to an object returned by
apt_pkg.GetPackageManager().
apt_pkg.PackageManager().
The second parameter *install_progress* refers to an InstallProgress()
object of the module apt.progress.
......@@ -309,8 +309,8 @@ class Cache(object):
if install_progress is None:
install_progress = apt.progress.InstallProgress()
pm = apt_pkg.GetPackageManager(self._depcache)
fetcher = apt_pkg.GetAcquire(fetch_progress)
pm = apt_pkg.PackageManager(self._depcache)
fetcher = apt_pkg.Acquire(fetch_progress)
while True:
# fetch archives first
res = self._fetch_archives(fetcher, pm)
......@@ -494,8 +494,8 @@ def _test():
if not os.path.exists(dir):
os.mkdir(dir)
apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest")
pm = apt_pkg.GetPackageManager(cache._depcache)
fetcher = apt_pkg.GetAcquire(apt.progress.TextFetchProgress())
pm = apt_pkg.PackageManager(cache._depcache)
fetcher = apt_pkg.Acquire(apt.progress.TextFetchProgress())
cache._fetch_archives(fetcher, pm)
#sys.exit(1)
......
......@@ -45,7 +45,7 @@ class Cdrom(object):
"""
def __init__(self, progress=None, mountpoint=None, nomount=True):
self._cdrom = apt_pkg.GetCdrom()
self._cdrom = apt_pkg.Cdrom()
if progress is None:
self._progress = CdromProgress()
else:
......
......@@ -57,7 +57,7 @@ class DebPackage(object):
"missing '%s' member" %
"debian-binary"))
control = apt_inst.debExtractControl(open(self.filename))
self._sections = apt_pkg.ParseSection(control)
self._sections = apt_pkg.TagSection(control)
self.pkgname = self._sections["Package"]
def __getitem__(self, key):
......@@ -357,7 +357,7 @@ class DebPackage(object):
"""Satisfy the dependencies."""
# turn off MarkAndSweep via a action group (if available)
try:
_actiongroup = apt_pkg.GetPkgActionGroup(self._cache._depcache)
_actiongroup = apt_pkg.ActionGroup(self._cache._depcache)
except AttributeError:
pass
# check depends
......@@ -458,7 +458,7 @@ class DscSrcPackage(DebPackage):
conflicts_tags = ["Build-Conflicts", "Build-Conflicts-Indep"]
fobj = open(file)
tagfile = apt_pkg.ParseTagFile(fobj)
tagfile = apt_pkg.TagFile(fobj)
sec = tagfile.Section
try:
while tagfile.Step() == 1:
......
......@@ -158,7 +158,7 @@ class Record(Mapping):
"""
def __init__(self, record_str):
self._rec = apt_pkg.ParseSection(record_str)
self._rec = apt_pkg.TagSection(record_str)
def __hash__(self):
return hash(self._rec)
......@@ -448,9 +448,9 @@ class Version(object):
if _file_is_same(destfile, self.size, self._records.MD5Hash):
print 'Ignoring already existing file:', destfile
return
acq = apt_pkg.GetAcquire(progress or apt.progress.TextFetchProgress())
apt_pkg.GetPkgAcqFile(acq, self.uri, self._records.MD5Hash, self.size,
base, destFile=destfile)
acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress())
apt_pkg.AcquireFile(acq, self.uri, self._records.MD5Hash, self.size,
base, destfile=destfile)
acq.Run()
for item in acq.Items:
if item.Status != item.StatDone:
......@@ -474,8 +474,8 @@ class Version(object):
If *unpack* is ``True``, the path to the extracted directory is
returned. Otherwise, the path to the .dsc file is returned.
"""
src = apt_pkg.GetPkgSrcRecords()
acq = apt_pkg.GetAcquire(progress or apt.progress.TextFetchProgress())
src = apt_pkg.SourceRecords()
acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress())
dsc = None
src.Lookup(self.package.name)
......@@ -497,8 +497,8 @@ class Version(object):
continue
finally:
fobj.close()
apt_pkg.GetPkgAcqFile(acq, src.Index.ArchiveURI(path), md5, size,
base, destFile=destfile)
apt_pkg.AcquireFile(acq, src.Index.ArchiveURI(path), md5, size,
base, destfile=destfile)
acq.Run()
for item in acq.Items:
......@@ -879,7 +879,7 @@ class Package(object):
# this feature only works if the correct deb-src are in the
# sources.list
# otherwise we fall back to the binary version number
src_records = apt_pkg.GetPkgSrcRecords()
src_records = apt_pkg.SourceRecords()
src_rec = src_records.Lookup(src_pkg)
if src_rec:
src_ver = src_records.Version
......@@ -1016,7 +1016,7 @@ class Package(object):
self._pcache._depcache.MarkDelete(self._pkg, purge)
# try to fix broken stuffsta
if auto_fix and self._pcache._depcache.BrokenCount > 0:
fix = apt_pkg.GetPkgProblemResolver(self._pcache._depcache)
fix = apt_pkg.ProblemResolver(self._pcache._depcache)
fix.Clear(self._pkg)
fix.Protect(self._pkg)
fix.Remove(self._pkg)
......@@ -1043,7 +1043,7 @@ class Package(object):
self._pcache._depcache.MarkInstall(self._pkg, auto_inst, from_user)
# try to fix broken stuff
if auto_fix and self._pcache._depcache.BrokenCount > 0:
fixer = apt_pkg.GetPkgProblemResolver(self._pcache._depcache)
fixer = apt_pkg.ProblemResolver(self._pcache._depcache)
fixer.Clear(self._pkg)
fixer.Protect(self._pkg)
fixer.Resolve(True)
......
......@@ -4,10 +4,10 @@ import apt_pkg
import os
def get_file(fetcher, uri, destFile):
def get_file(fetcher, uri, destfile):
# get the file
af = apt_pkg.GetPkgAcqFile(fetcher, uri=uri, descr="sample descr",
destFile=destFile)
af = apt_pkg.AcquireFile(fetcher, uri=uri, descr="sample descr",
destfile=destfile)
res = fetcher.Run()
if res != fetcher.ResultContinue:
return False
......@@ -19,21 +19,21 @@ apt_pkg.init()
#apt_pkg.Config.Set("Debug::pkgPackageManager","1");
#apt_pkg.Config.Set("Debug::pkgDPkgProgressReporting","1");
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
recs = apt_pkg.GetPkgRecords(cache)
list = apt_pkg.GetPkgSourceList()
recs = apt_pkg.PackageRecords(cache)
list = apt_pkg.SourceList()
list.ReadMainList()
# show the amount fetch needed for a dist-upgrade
depcache.Upgrade(True)
progress = apt.progress.TextFetchProgress()
fetcher = apt_pkg.GetAcquire(progress)
pm = apt_pkg.GetPackageManager(depcache)
fetcher = apt_pkg.Acquire(progress)
pm = apt_pkg.PackageManager(depcache)
pm.GetArchives(fetcher, list, recs)
print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded)
actiongroup = apt_pkg.GetPkgActionGroup(depcache)
actiongroup = apt_pkg.ActionGroup(depcache)
for pkg in cache.Packages:
depcache.MarkKeep(pkg)
......@@ -48,9 +48,9 @@ pkg = cache["3ddesktop"]
depcache.MarkInstall(pkg)
progress = apt.progress.TextFetchProgress()
fetcher = apt_pkg.GetAcquire(progress)
#fetcher = apt_pkg.GetAcquire()
pm = apt_pkg.GetPackageManager(depcache)
fetcher = apt_pkg.Acquire(progress)
#fetcher = apt_pkg.Acquire()
pm = apt_pkg.PackageManager(depcache)
print pm
print fetcher
......
......@@ -10,7 +10,7 @@ from progress import TextFetchProgress
apt_pkg.init()
progress = OpTextProgress()
cache = apt_pkg.GetCache(progress)
cache = apt_pkg.Cache(progress)
print "Available packages: %s " % cache.PackageCount
print "Fetching"
......@@ -25,7 +25,7 @@ print "example package iter: %s" % iter
# get depcache
print "\n\n depcache"
depcache = apt_pkg.GetDepCache(cache, progress)
depcache = apt_pkg.DepCache(cache, progress)
depcache.ReadPinFile()
print "got a depcache: %s " % depcache
print "Marked for install: %s " % depcache.InstCount
......
......@@ -21,11 +21,11 @@ def get_source_pkg(pkg, records, depcache):
# main
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
depcache.Init()
records = apt_pkg.GetPkgRecords(cache)
srcrecords = apt_pkg.GetPkgSrcRecords()
records = apt_pkg.PackageRecords(cache)
srcrecords = apt_pkg.SourceRecords()
# base package that we use for build-depends calculation
if len(sys.argv) < 2:
......
......@@ -10,7 +10,7 @@ from progress import TextCdromProgress
# init
apt_pkg.init()
cdrom = apt_pkg.GetCdrom()
cdrom = apt_pkg.Cdrom()
print cdrom
progress = TextCdromProgress()
......
......@@ -8,7 +8,7 @@
import apt_pkg
apt_pkg.init()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
packages = cache.Packages
uninstalled, updated, upgradable = {}, {}, {}
......
......@@ -21,7 +21,7 @@ import posixpath
# configuration object apt_pkg.Config which is used interally by apt-pkg
# routines to control unusual situations. I recommend using the sytem global
# whenever possible..
Cnf = apt_pkg.newConfiguration()
Cnf = apt_pkg.Configuration()
print "Command line is", sys.argv
......
......@@ -17,7 +17,7 @@ if len(ConfigFile) != 1:
print "Must have exactly 1 file name"
sys.exit(0)
Cnf = apt_pkg.newConfiguration()
Cnf = apt_pkg.Configuration()
apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0])
# Print the configuration space
......
......@@ -25,7 +25,7 @@ if __name__ == "__main__":
print "Now extracting the control file:"
control = apt_inst.debExtractControl(open(file))
sections = apt_pkg.ParseSection(control)
sections = apt_pkg.TagSection(control)
print "Maintainer is: "
print sections["Maintainer"]
......
......@@ -9,7 +9,7 @@ from progress import TextProgress
apt_pkg.init()
progress = TextProgress()
cache = apt_pkg.GetCache(progress)
cache = apt_pkg.Cache(progress)
print "Available packages: %s " % cache.PackageCount
iter = cache["base-config"]
......@@ -17,7 +17,7 @@ print "example package iter: %s" % iter
# get depcache
print "\n\n depcache"
depcache = apt_pkg.GetDepCache(cache)
depcache = apt_pkg.DepCache(cache)
depcache.ReadPinFile()
# init is needed after the creation/pin file reading
depcache.Init(progress)
......
......@@ -6,8 +6,8 @@ apt_pkg.init()
apt_pkg.Config.Set("APT::Acquire::Translation", "de")
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
pkg = cache["gcc"]
cand = depcache.GetCandidateVer(pkg)
......@@ -18,7 +18,7 @@ print desc
print desc.FileList
(f, index) = desc.FileList.pop(0)
records = apt_pkg.GetPkgRecords(cache)
records = apt_pkg.PackageRecords(cache)
records.Lookup((f, index))
desc = records.LongDesc
print len(desc)
......
......@@ -4,11 +4,11 @@ import apt_pkg
apt_pkg.init()
sources = apt_pkg.GetPkgSourceList()
sources = apt_pkg.SourceList()
sources.ReadMainList()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
pkg = cache["libimlib2"]
cand = depcache.GetCandidateVer(pkg)
for (f, i) in cand.FileList:
......
......@@ -4,7 +4,7 @@ import apt_pkg
apt_pkg.init()
sources = apt_pkg.GetPkgSourceList()
sources = apt_pkg.SourceList()
sources.ReadMainList()
......
......@@ -13,7 +13,7 @@ upgradable = filter(lambda p: p.isUpgradable, cache)
for pkg in upgradable:
pkg._lookupRecord(True)
path = apt_pkg.ParseSection(pkg._records.Record)["Filename"]
path = apt_pkg.TagSection(pkg._records.Record)["Filename"]
cand = pkg._depcache.GetCandidateVer(pkg._pkg)
for (packagefile, i) in cand.FileList:
indexfile = cache._list.FindIndex(packagefile)
......
......@@ -3,7 +3,7 @@
import apt_pkg
apt_pkg.init()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
class Wanted:
......
......@@ -4,10 +4,10 @@ import apt_pkg
apt_pkg.init()
#cache = apt_pkg.GetCache()
#sources = apt_pkg.GetPkgSrcRecords(cache)
#cache = apt_pkg.Cache()
#sources = apt_pkg.SourceRecords(cache)
sources = apt_pkg.GetPkgSrcRecords()
sources = apt_pkg.SourceRecords()
sources.Restart()
while sources.Lookup('hello'):
print sources.Package, sources.Version, sources.Maintainer, \
......
#!/usr/bin/env python
import apt_pkg
Parse = apt_pkg.ParseTagFile(open("/var/lib/dpkg/status", "r"))
Parse = apt_pkg.TagFile(open("/var/lib/dpkg/status", "r"))
while Parse.Step() == 1:
print Parse.Section.get("Package")
......
......@@ -8,7 +8,7 @@ def main():
"""Main."""
apt_pkg.InitConfig()
apt_pkg.InitSystem()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
print "Essential packages:"
for pkg in cache.Packages:
if pkg.Essential:
......
......@@ -5,7 +5,7 @@ import apt_pkg
def main():
"""Example for PackageFile()"""
apt_pkg.init()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
for pkgfile in cache.FileList:
print 'Package-File:', pkgfile.FileName
print 'Index-Type:', pkgfile.IndexType # 'Debian Package Index'
......
......@@ -35,7 +35,7 @@ def main():
apt_pkg.InitConfig()
apt_pkg.InitSystem()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
for pkg in sorted(cache.Packages, key=lambda pkg: pkg.Name):
# pkg is from a list of packages, sorted by name.
......
......@@ -9,8 +9,8 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
depcache.Init()
i=0
all=cache.PackageCount
......
......@@ -9,8 +9,8 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
depcache.Init()
i=0
all=cache.PackageCount
......
......@@ -13,12 +13,12 @@ class TestGetCache(unittest.TestCase):
def testWrongInvocation(self):
# wrongly invoke GetCache() rather than GetDepCache()
apt_cache = apt_pkg.GetCache()
self.assertRaises(ValueError, apt_pkg.GetCache, apt_cache)
apt_cache = apt_pkg.Cache()
self.assertRaises(ValueError, apt_pkg.Cache, apt_cache)
def testProperInvocation(self):
apt_cache = apt_pkg.GetCache(apt.progress.OpTextProgress())
apt_depcache = apt_pkg.GetDepCache(apt_cache)
apt_cache = apt_pkg.Cache(apt.progress.OpTextProgress())
apt_depcache = apt_pkg.DepCache(apt_cache)
if __name__ == "__main__":
unittest.main()
......@@ -29,10 +29,10 @@ for i in range(100):
# no memleak, but more or less the apt.Cache.open() code
for i in range(100):
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
records = apt_pkg.GetPkgRecords(cache)
list = apt_pkg.GetPkgSourceList()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
records = apt_pkg.PackageRecords(cache)
list = apt_pkg.SourceList()
list.ReadMainList()
dict = {}
for pkg in cache.Packages:
......
......@@ -9,8 +9,8 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
depcache.Init()
i=0
all=cache.PackageCount
......@@ -25,7 +25,7 @@ def main():
if ver is not None:
depcache.MarkInstall(pkg)
if depcache.BrokenCount > 0:
fixer = apt_pkg.GetPkgProblemResolver(depcache)
fixer = apt_pkg.ProblemResolver(depcache)
fixer.Clear(pkg)
fixer.Protect(pkg)
# we first try to resolve the problem
......
......@@ -10,14 +10,14 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
depcache.Init()
i=0
print "Running PkgRecords test on all packages:"
for pkg in cache.Packages:
i += 1
records = apt_pkg.GetPkgRecords(cache)
records = apt_pkg.PackageRecords(cache)
if len(pkg.VersionList) == 0:
#print "no available version, cruft"
continue
......
......@@ -10,12 +10,12 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.GetCache()
cache = apt_pkg.Cache()
i=0
print "Running PkgSrcRecords test on all packages:"
for x in cache.Packages:
i += 1
src = apt_pkg.GetPkgSrcRecords()
src = apt_pkg.SourceRecords()
if src.Lookup(x.Name):
#print src.Package
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment