summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-03-12 11:42:37 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-03-12 11:42:37 +0100
commit85238ea03cd35b48a90a2fc1f63f2cf05d5b83b4 (patch)
treebb7fcce7e80cc45e807eab19a3c36f628c888bd3 /apt/cache.py
parent62a7342edb16c38e3d646cc731a4a50ad6657b4f (diff)
parentc657b7a2a59e15a0c415ba94021c4de547a78e60 (diff)
downloadpython-apt-85238ea03cd35b48a90a2fc1f63f2cf05d5b83b4.tar.gz
merged from debian-sid
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/apt/cache.py b/apt/cache.py
index b5733d98..2e6d24e5 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -46,17 +46,21 @@ class Cache(object):
"""Dictionary-like package cache.
This class has all the packages that are available in it's
- dictionary.
+ dictionary.
Keyword arguments:
progress -- a OpProgress object
- rootdir -- a alternative root directory. if that is given
- the system sources.list and system lists/ files are
+ rootdir -- a alternative root directory. if that is given
+ the system sources.list and system lists/ files are
not read, only files relative to the given rootdir
memonly -- build the cache in memory only
"""
def __init__(self, progress=None, rootdir=None, memonly=False):
+ self._cache = None
+ self._depcache = None
+ self._records = None
+ self._list = None
self._callbacks = {}
self._weakref = weakref.WeakValueDictionary()
self._set = set()
@@ -95,12 +99,12 @@ class Cache(object):
"/var/lib/apt/lists/partial",
]
for d in dirs:
- if not os.path.exists(rootdir+d):
- print "creating: ",rootdir+d
- os.makedirs(rootdir+d)
+ if not os.path.exists(rootdir + d):
+ print "creating: ", rootdir + d
+ os.makedirs(rootdir + d)
for f in files:
- if not os.path.exists(rootdir+f):
- open(rootdir+f,"w")
+ if not os.path.exists(rootdir + f):
+ open(rootdir + f, "w")
def _run_callbacks(self, name):
""" internal helper to run a callback """
@@ -125,12 +129,12 @@ class Cache(object):
self._weakref.clear()
progress.op = _("Building data structures")
- i=last=0
- size=len(self._cache.packages)
+ i = last = 0
+ size = len(self._cache.packages)
for pkg in self._cache.packages:
if progress is not None and last+100 < i:
progress.update(i/float(size)*100)
- last=i
+ last = i
# drop stuff with no versions (cruft)
if len(pkg.version_list) > 0:
self._set.add(pkg.name)
@@ -376,9 +380,10 @@ class Cache(object):
elif res == pm.RESULT_FAILED:
raise SystemError("installArchives() failed")
elif res == pm.RESULT_INCOMPLETE:
- pass
+ pass
else:
- raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res)
+ raise SystemError("internal-error: unknown result code "
+ "from InstallArchives: %s" % res)
# reload the fetcher for media swaping
fetcher.shutdown()
return (res == pm.RESULT_COMPLETED)
@@ -623,9 +628,9 @@ def _test():
# see if fetching works
- for dir in ["/tmp/pytest", "/tmp/pytest/partial"]:
- if not os.path.exists(dir):
- os.mkdir(dir)
+ for dirname in ["/tmp/pytest", "/tmp/pytest/partial"]:
+ if not os.path.exists(dirname):
+ os.mkdir(dirname)
apt_pkg.config.set("Dir::Cache::Archives", "/tmp/pytest")
pm = apt_pkg.PackageManager(cache._depcache)
fetcher = apt_pkg.Acquire(apt.progress.text.AcquireProgress())