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"]
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")
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"]
metadata.pop(k, None)
keys = metadata.keys()
keys.sort()
- writepkgindex(pkgfile,
+ self._writepkgindex(pkgfile,
[(k, metadata[k]) for k in keys if metadata[k]])