Make readpkgindex() and writepkgindex() private methods of PackageIndex. v2.2_pre4
authorZac Medico <zmedico@gentoo.org>
Sat, 8 Mar 2008 00:21:15 +0000 (00:21 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 8 Mar 2008 00:21:15 +0000 (00:21 -0000)
svn path=/main/trunk/; revision=9453

pym/portage/getbinpkg.py

index e3f97e7a23f81e0cf0c3bd478a01423f6a9282a9..1470076592a92dd99b53fba60a86fcab61803e98 100644 (file)
@@ -655,26 +655,6 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        
        return metadata[baseurl]["data"]
 
-def readpkgindex(pkgfile):
-       d = {}
-       for line in pkgfile:
-               line = line.rstrip("\n")
-               if not line:
-                       break
-               line = line.split(":", 1)
-               if not len(line) == 2:
-                       continue
-               k, v = line
-               if v:
-                       v = v[1:]
-               d[k] = v
-       return d
-
-def writepkgindex(pkgfile, items):
-       for k, v in items:
-               pkgfile.write("%s: %s\n" % (k, v))
-       pkgfile.write("\n")
-
 def _cmp_cpv(d1, d2):
        cpv1 = d1["CPV"]
        cpv2 = d2["CPV"]
@@ -694,16 +674,36 @@ class PackageIndex(object):
                self.packages = []
                self.modified = True
 
+       def _readpkgindex(self, pkgfile):
+               d = {}
+               for line in pkgfile:
+                       line = line.rstrip("\n")
+                       if not line:
+                               break
+                       line = line.split(":", 1)
+                       if not len(line) == 2:
+                               continue
+                       k, v = line
+                       if v:
+                               v = v[1:]
+                       d[k] = v
+               return d
+       
+       def _writepkgindex(self, pkgfile, items):
+               for k, v in items:
+                       pkgfile.write("%s: %s\n" % (k, v))
+               pkgfile.write("\n")
+
        def read(self, pkgfile):
                self.readHeader(pkgfile)
                self.readBody(pkgfile)
 
        def readHeader(self, pkgfile):
-               self.header.update(readpkgindex(pkgfile))
+               self.header.update(self._readpkgindex(pkgfile))
 
        def readBody(self, pkgfile):
                while True:
-                       d = readpkgindex(pkgfile)
+                       d = self._readpkgindex(pkgfile)
                        if not d:
                                break
                        mycpv = d.get("CPV")
@@ -725,7 +725,7 @@ class PackageIndex(object):
                        self.header["PACKAGES"] = str(len(self.packages))
                keys = self.header.keys()
                keys.sort()
-               writepkgindex(pkgfile, [(k, self.header[k]) for k in keys])
+               self._writepkgindex(pkgfile, [(k, self.header[k]) for k in keys])
                for metadata in sorted(self.packages, _cmp_cpv):
                        metadata = metadata.copy()
                        cpv = metadata["CPV"]
@@ -740,5 +740,5 @@ class PackageIndex(object):
                                                metadata.pop(k, None)
                        keys = metadata.keys()
                        keys.sort()
-                       writepkgindex(pkgfile,
+                       self._writepkgindex(pkgfile,
                                [(k, metadata[k]) for k in keys if metadata[k]])