summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-08 00:21:15 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-08 00:21:15 +0000
commit667d452ee7d2c0948ef03223e31c7b87e9e3129d (patch)
treed4f74235e3031e6848967067286a42f7d363c10d
parent6898735370872391ea2beb19d7366070f207d170 (diff)
downloadportage-667d452ee7d2c0948ef03223e31c7b87e9e3129d.tar.gz
portage-667d452ee7d2c0948ef03223e31c7b87e9e3129d.tar.bz2
portage-667d452ee7d2c0948ef03223e31c7b87e9e3129d.zip
Make readpkgindex() and writepkgindex() private methods of PackageIndex.v2.2_pre4
svn path=/main/trunk/; revision=9453
-rw-r--r--pym/portage/getbinpkg.py48
1 files changed, 24 insertions, 24 deletions
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index e3f97e7a2..147007659 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -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]])