From 667d452ee7d2c0948ef03223e31c7b87e9e3129d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 8 Mar 2008 00:21:15 +0000 Subject: [PATCH] Make readpkgindex() and writepkgindex() private methods of PackageIndex. svn path=/main/trunk/; revision=9453 --- pym/portage/getbinpkg.py | 48 ++++++++++++++++++++-------------------- 1 file 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]]) -- 2.26.2