summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-04-07 23:10:30 +0000
committerZac Medico <zmedico@gentoo.org>2008-04-07 23:10:30 +0000
commit5053cb60a46add9f54ea6678d7ff6da040119df7 (patch)
tree86387cafb8c607ad4857c508302025d4528f19e1
parent2527a0bc8f3fc9be217e0ab5b31468d2b36718f6 (diff)
downloadportage-5053cb60a46add9f54ea6678d7ff6da040119df7.tar.gz
portage-5053cb60a46add9f54ea6678d7ff6da040119df7.tar.bz2
portage-5053cb60a46add9f54ea6678d7ff6da040119df7.zip
When reading and writing the Packages index file, translate metadata keys
on the fly. Current translations: DESC <-> DESCRIPTION REPO <-> repository svn path=/main/trunk/; revision=9742
-rw-r--r--pym/portage/dbapi/bintree.py9
-rw-r--r--pym/portage/getbinpkg.py14
2 files changed, 16 insertions, 7 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index d2b499ba1..8b2ffbe0f 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -174,6 +174,10 @@ class binarytree(object):
self._pkgindex_default_header_data = {
"repository":""
}
+ self._pkgindex_translated_keys = (
+ ("DESCRIPTION" , "DESC"),
+ ("repository" , "REPO"),
+ )
def move_ent(self, mylist):
if not self.populated:
@@ -811,7 +815,8 @@ class binarytree(object):
return portage.getbinpkg.PackageIndex(
default_header_data=self._pkgindex_default_header_data,
default_pkg_data=self._pkgindex_default_pkg_data,
- inherited_keys=self._pkgindex_inherited_keys)
+ inherited_keys=self._pkgindex_inherited_keys,
+ translated_keys=self._pkgindex_translated_keys)
def _update_pkgindex_header(self, header):
portdir = normalize_path(os.path.realpath(self.settings["PORTDIR"]))
@@ -846,8 +851,6 @@ class binarytree(object):
return False
def _eval_use_flags(self, cpv, metadata):
- metadata["DESC"] = metadata["DESCRIPTION"]
- del metadata["DESCRIPTION"]
use = metadata["USE"].split()
raw_use = use
iuse = set(f.lstrip("-+") for f in metadata["IUSE"].split())
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index 376767957..9e03b1f0e 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -668,10 +668,15 @@ def _cmp_cpv(d1, d2):
class PackageIndex(object):
def __init__(self, default_header_data=None, default_pkg_data=None,
- inherited_keys=None):
+ inherited_keys=None, translated_keys=None):
self._default_header_data = default_header_data
self._default_pkg_data = default_pkg_data
self._inherited_keys = inherited_keys
+ self._write_translation_map = {}
+ self._read_translation_map = {}
+ if translated_keys:
+ self._write_translation_map.update(translated_keys)
+ self._read_translation_map.update(((y, x) for (x, y) in translated_keys))
self.header = {}
if self._default_header_data:
self.header.update(self._default_header_data)
@@ -690,12 +695,13 @@ class PackageIndex(object):
k, v = line
if v:
v = v[1:]
- d[k] = v
+ d[self._read_translation_map.get(k, k)] = v
return d
-
+
def _writepkgindex(self, pkgfile, items):
for k, v in items:
- pkgfile.write("%s: %s\n" % (k, v))
+ pkgfile.write("%s: %s\n" % \
+ (self._write_translation_map.get(k, k), v))
pkgfile.write("\n")
def read(self, pkgfile):