From e99da71e5f242787ec39714e55b5fa08bfe071eb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 19 Oct 2011 18:24:24 +0200 Subject: rm usage of camelcase in cache.py doc (closes: #626617) --- apt/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index be137b76..49097dd2 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -507,7 +507,7 @@ class Cache(object): self._callbacks[name].append(callback) def actiongroup(self): - """Return an ActionGroup() object for the current cache. + """Return an action group object for the current cache. Action groups can be used to speedup actions. The action group is active as soon as it is created, and disabled when the object is @@ -520,7 +520,7 @@ class Cache(object): for package in my_selected_packages: package.mark_install() - This way, the ActionGroup is automatically released as soon as the + This way, the action group is automatically released as soon as the with statement block is left. It also has the benefit of making it clear which parts of the code run with a action group and which don't. -- cgit v1.2.3 From 2089dda15fd6dd2734c395a9840c06e467c76325 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 19 Oct 2011 18:25:43 +0200 Subject: grammar fix in the cache.py doc (closes: #626610) --- apt/cache.py | 3 +-- debian/changelog | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 49097dd2..bab5c277 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -46,8 +46,7 @@ class LockFailedException(IOError): class Cache(object): """Dictionary-like package cache. - This class has all the packages that are available in it's - dictionary. + The dictionary of this class contains all available packages. Keyword arguments: progress -- a OpProgress object diff --git a/debian/changelog b/debian/changelog index 7fa0f624..15562c04 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ python-apt (0.8.2) UNRELEASED; urgency=low [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) + * grammar fix in the cache.py doc (closes: #626610) -- Michael Vogt Wed, 19 Oct 2011 18:03:42 +0200 -- cgit v1.2.3 From 1948d5d03887eb81ea7797c0f23049ef6c3895ce Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 10 Nov 2011 10:05:55 +0100 Subject: * apt/cache.py: - remove "print" when creating dirs in apt.Cache(rootdir=dir), thanks to Martin Pitt --- apt/cache.py | 2 +- debian/changelog | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index bab5c277..a4585277 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -111,7 +111,7 @@ class Cache(object): ] for d in dirs: if not os.path.exists(rootdir + d): - print "creating: ", rootdir + d + #print "creating: ", rootdir + d os.makedirs(rootdir + d) for f in files: if not os.path.exists(rootdir + f): diff --git a/debian/changelog b/debian/changelog index 6fbc5241..f5ae2b79 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,9 @@ python-apt (0.8.2) UNRELEASED; urgency=low - updated, thanks to Nikola Nenadic (closes: #638308) * python/apt_pkgmodule.cc: - add apt_pkg.get_architectures() call + * apt/cache.py: + - remove "print" when creating dirs in apt.Cache(rootdir=dir), + thanks to Martin Pitt [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3 From fcd268692450231c98bfb6ac2e573ce466e014c7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 14 Nov 2011 14:07:38 +0100 Subject: * apt/cache.py: - set Dir::bin::dpkg if a alternate rootdir is given (LP: #885895) --- apt/cache.py | 4 ++++ debian/changelog | 3 +++ 2 files changed, 7 insertions(+) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index a4585277..8a456715 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -83,6 +83,10 @@ class Cache(object): apt_pkg.config.set("Dir", rootdir) apt_pkg.config.set("Dir::State::status", rootdir + "/var/lib/dpkg/status") + # also set dpkg to the rootdir path so that its called for the + # --print-foreign-architectures call + apt_pkg.config.set("Dir::bin::dpkg", + os.path.join(rootdir, "usr", "bin", "dpkg")) # create required dirs/files when run with special rootdir # automatically self._check_and_create_required_dirs(rootdir) diff --git a/debian/changelog b/debian/changelog index 58326dc2..14ee705e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,9 @@ python-apt (0.8.2) UNRELEASED; urgency=low - remove "print" when creating dirs in apt.Cache(rootdir=dir), thanks to Martin Pitt * fix build against apt in experimental + * apt/cache.py: + - set Dir::bin::dpkg if a alternate rootdir is given + (LP: #885895) [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) -- cgit v1.2.3 From b7b608bf2c66e7466313ea02568348aea9cc29ba Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Nov 2011 18:01:26 +0100 Subject: cleanup based on feedback from juliank --- apt/cache.py | 10 ++++++++-- apt/debfile.py | 19 +++++++++++++------ debian/changelog | 6 +++--- tests/test_debfile.py | 12 +++++++----- 4 files changed, 31 insertions(+), 16 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 8a456715..b4d67fa5 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -46,7 +46,13 @@ class LockFailedException(IOError): class Cache(object): """Dictionary-like package cache. - The dictionary of this class contains all available packages. + The APT cache file contains a hash table mapping names of binary + packages to their metadata. A Cache object is the in-core + representation of the same. It provides access to APTs idea of the + list of available packages. + + The cache can be used like a mapping from package names to Package + objects (although only getting items is supported). Keyword arguments: progress -- a OpProgress object @@ -510,7 +516,7 @@ class Cache(object): self._callbacks[name].append(callback) def actiongroup(self): - """Return an action group object for the current cache. + """Return an `ActionGroup` object for the current cache. Action groups can be used to speedup actions. The action group is active as soon as it is created, and disabled when the object is diff --git a/apt/debfile.py b/apt/debfile.py index 104b0814..5b9274b2 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -53,6 +53,7 @@ class DebPackage(object): self.pkgname = "" self._sections = {} self._need_pkgs = [] + self._check_was_run = False self._failure_string = "" if filename: self.open(filename) @@ -68,7 +69,8 @@ class DebPackage(object): control = self._debfile.control.extractdata("control") self._sections = apt_pkg.TagSection(control) self.pkgname = self._sections["Package"] - + self._check_was_run = False + def __getitem__(self, key): return self._sections[key] @@ -393,6 +395,8 @@ class DebPackage(object): """Check if the package is installable.""" self._dbg(3, "check") + self._check_was_run = True + # check arch if not "Architecture" in self._sections: self._dbg(1, "ERROR: no architecture field") @@ -472,8 +476,8 @@ class DebPackage(object): def missing_deps(self): """Return missing dependencies.""" self._dbg(1, "Installing: %s" % self._need_pkgs) - if not self._need_pkgs: - self.check() + if not self._check_was_run: + raise ValueError("property only available after check() was run") return self._need_pkgs @property @@ -485,8 +489,8 @@ class DebPackage(object): install = [] remove = [] unauthenticated = [] - if not self._cache: - self.check() + if not self._check_was_run: + raise ValueError("property only available after check() was run") for pkg in self._cache: if pkg.marked_install or pkg.marked_upgrade: install.append(pkg.name) @@ -641,7 +645,8 @@ class DscSrcPackage(DebPackage): "source package '%s' that builds %s\n") % (self.pkgname, " ".join(self.binaries)) self._sections["Description"] = s - + self._check_was_run = False + def check(self): """Check if the package is installable..""" if not self.check_conflicts(): @@ -649,6 +654,8 @@ class DscSrcPackage(DebPackage): if self._cache[pkgname]._pkg.essential: raise Exception(_("An essential package would be removed")) self._cache[pkgname].mark_delete() + # properties are ok now + self._check_was_run = True # FIXME: a additional run of the check_conflicts() # after _satisfy_depends() should probably be done return self._satisfy_depends(self.depends) diff --git a/debian/changelog b/debian/changelog index 27eb8e97..cc922735 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,13 +26,13 @@ python-apt (0.8.2) UNRELEASED; urgency=low - set Dir::bin::dpkg if a alternate rootdir is given (LP: #885895) * build fixes for the apt in experimental + * apt/debfile.py: raise error when accessing require_changes and + missing_deps without calling check() before, thanks to + Tshepang Lekhonkhobe (closes: #624379) [ Tshepang Lekhonkhobe ] * rm usage of camelcase in cache.py doc (closes: #626617) * grammar fix in the cache.py doc (closes: #626610) - * apt/debfile.py: Remove the need to explcitly call check() in order - to get output from require_changes and missing_deps - (closes: #624379) -- Michael Vogt Wed, 19 Oct 2011 18:03:42 +0200 diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 501b8f61..e6c475d3 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -88,11 +88,6 @@ class TestDebfilee(unittest.TestCase): "Samuel Lidén Borell ") def test_content(self): - # no python-debian for python3 yet, so fail gracefully - try: - import debian - except ImportError: - return # normal deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) @@ -119,6 +114,13 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") self.assertEqual(deb.filelist, ["./", "usr/", "usr/bin/"]) + def test_check_exception(self): + deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb") + with self.assertRaises(ValueError): + deb.missing_deps + deb.check() + deb.missing_deps + def test_no_supported_data_tar(self): # ensure that a unknown data.tar.xxx raises a exception raised = False -- cgit v1.2.3 From 0af443d9a182b0fec5f9963edef3c1f1908e831f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 22 Nov 2011 18:06:30 +0100 Subject: cleanup --- apt/cache.py | 14 +++++++------- apt/debfile.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index b4d67fa5..96b38a57 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -46,13 +46,13 @@ class LockFailedException(IOError): class Cache(object): """Dictionary-like package cache. - The APT cache file contains a hash table mapping names of binary - packages to their metadata. A Cache object is the in-core - representation of the same. It provides access to APTs idea of the - list of available packages. - - The cache can be used like a mapping from package names to Package - objects (although only getting items is supported). + The APT cache file contains a hash table mapping names of binary + packages to their metadata. A Cache object is the in-core + representation of the same. It provides access to APTs idea of the + list of available packages. + + The cache can be used like a mapping from package names to Package + objects (although only getting items is supported). Keyword arguments: progress -- a OpProgress object diff --git a/apt/debfile.py b/apt/debfile.py index 5b9274b2..277262d7 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -477,7 +477,7 @@ class DebPackage(object): """Return missing dependencies.""" self._dbg(1, "Installing: %s" % self._need_pkgs) if not self._check_was_run: - raise ValueError("property only available after check() was run") + raise AttributeError("property only available after check() was run") return self._need_pkgs @property @@ -490,7 +490,7 @@ class DebPackage(object): remove = [] unauthenticated = [] if not self._check_was_run: - raise ValueError("property only available after check() was run") + raise AttributeError("property only available after check() was run") for pkg in self._cache: if pkg.marked_install or pkg.marked_upgrade: install.append(pkg.name) -- cgit v1.2.3 From 23d4a5fc9ca8dc7a35fd96a48dcb261ac0daf46b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Mar 2012 10:19:51 +0200 Subject: * apt/cache.py: - fix _have_multi_arch flag (thanks to Sebastian Heinlein) --- apt/cache.py | 3 +-- debian/changelog | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 96b38a57..86a788bb 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -152,8 +152,7 @@ class Cache(object): self._sorted_set = None self._weakref.clear() - self._have_multi_arch = bool(apt_pkg.config.value_list("APT::" + - "Architectures")) + self._have_multi_arch = len(apt_pkg.get_architectures()) > 1 progress.op = _("Building data structures") i = last = 0 diff --git a/debian/changelog b/debian/changelog index b1bf28d6..a163f03a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ python-apt (0.8.4) UNRELEASED; urgency=low to the file object currently supported) * apt/package.py: - if there is no Version.uri return None + * apt/cache.py: + - fix _have_multi_arch flag (thanks to Sebastian Heinlein) -- Michael Vogt Wed, 04 Jan 2012 12:07:48 +0100 -- cgit v1.2.3