[Piuparts-commits] [piuparts] 15/20: lib/db: PackagesFile: allow restricting to a set of package names

Holger Levsen holger at moszumanska.debian.org
Sat Nov 23 20:23:35 UTC 2013


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 609d56586a4899401f6b7c34dddf0e0f6727510c
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sun Nov 17 12:16:58 2013 +0100

    lib/db: PackagesFile: allow restricting to a set of package names
    
    reduce memory footprint if not all are needed
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 debian/changelog          |  2 ++
 piupartslib/packagesdb.py | 10 +++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 8e7b8a2..780f2c5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ piuparts (0.56) UNRELEASED; urgency=low
   * piupartslib/__init__.py:
     - open_packages_url(): Try Packages.gz if Packages.bz2 is not available.
       (Closes: #711157)
+  * piupartslib/packagesdb.py:
+    - PackagesFile: Allow restricting to a set of package names.
   * piuparts-slave.py:
     - Use locking to prevent concurrent basetgz creation.  (Closes: #708287)
     - Use the "components" setting to restrict the archive areas being used
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index b1a7810..5156181 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -135,16 +135,16 @@ class PackagesFile(UserDict.UserDict):
         UserDict.UserDict.__init__(self)
         self._urllist = []
 
-    def load_packages_urls(self, urls):
+    def load_packages_urls(self, urls, restrict_packages=None):
         for url in urls:
             logging.debug("Opening %s.*" % url)
             (url, stream) = piupartslib.open_packages_url(url)
             logging.debug("Fetching %s" % url)
-            self._read_file(stream)
+            self._read_file(stream, restrict_packages=restrict_packages)
             stream.close()
             self._urllist.append(url)
 
-    def _read_file(self, input):
+    def _read_file(self, input, restrict_packages=None):
         """Parse a Packages file and add its packages to us-the-dict"""
         while True:
             headers = rfc822_like_header_parse(input)
@@ -156,6 +156,10 @@ class PackagesFile(UserDict.UserDict):
                 if apt_pkg.version_compare(p["Version"], q["Version"]) <= 0:
                     # there is already a newer version
                     continue
+            if restrict_packages is not None:
+                if p["Package"] not in restrict_packages:
+                    # unwanted package
+                    continue
             self[p["Package"]] = p
 
     def get_urls(self):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list