summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-11-20 21:02:40 +0000
committerZac Medico <zmedico@gentoo.org>2008-11-20 21:02:40 +0000
commita95743183720c75f0af8a454dcef788d99a3851d (patch)
treeda2070218631e9270bed92a04e453a5ad52aa73c
parentb3f4024d3267e2b6348f1d3e3f07405ad68d1492 (diff)
downloadportage-a95743183720c75f0af8a454dcef788d99a3851d.tar.gz
portage-a95743183720c75f0af8a454dcef788d99a3851d.tar.bz2
portage-a95743183720c75f0af8a454dcef788d99a3851d.zip
Inside _parse_data(), don't rely on the magic 22 line count for the flat_list
format, since it doesn't make a significant performance difference and it places an artificial limit on the number of keys that can be stored. svn path=/main/trunk/; revision=12008
-rw-r--r--pym/portage/cache/metadata.py45
1 files changed, 18 insertions, 27 deletions
diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py
index 1c65ee8be..c3c83a019 100644
--- a/pym/portage/cache/metadata.py
+++ b/pym/portage/cache/metadata.py
@@ -3,7 +3,7 @@
# License: GPL2
# $Id$
-import os, stat, types
+import os, re, stat, types
from portage.cache import flat_hash
import portage.eclass_cache
from portage.cache.template import reconstruct_eclasses
@@ -22,6 +22,8 @@ class database(flat_hash.database):
autocommits = True
+ _hashed_re = re.compile('^(\\w+)=([^\n]*)')
+
def __init__(self, location, *args, **config):
loc = location
super(database, self).__init__(location, *args, **config)
@@ -33,34 +35,23 @@ class database(flat_hash.database):
def _parse_data(self, data, cpv):
- # easy attempt first.
+ _hashed_re_match = self._hashed_re.match
data = list(data)
- if len(data) != magic_line_count:
- d = flat_hash.database._parse_data(self, data, cpv)
- else:
- # this one's interesting.
- d = {}
-
- for line in data:
- # yes, meant to iterate over a string.
- hashed = False
- # poor mans enumerate. replace when python 2.3 is required
- for idx, c in zip(range(len(line)), line):
- if not c.isalpha():
- if c == "=" and idx > 0:
- hashed = True
- d[line[:idx]] = line[idx + 1:].rstrip("\n")
- elif c == "_" or c.isdigit():
- continue
- break
+ d = {}
- if not hashed:
- # non hashed.
- d.clear()
- # poor mans enumerate. replace when python 2.3 is required
- for idx, key in zip(range(len(self.auxdbkey_order)), self.auxdbkey_order):
- d[key] = data[idx].strip()
- break
+ for line in data:
+ hashed = False
+ hashed_match = _hashed_re_match(line)
+ if hashed_match is None:
+ d.clear()
+ try:
+ for i, key in enumerate(self.auxdbkey_order):
+ d[key] = data[i].rstrip("\n")
+ except IndexError:
+ pass
+ break
+ else:
+ d[hashed_match.group(1)] = hashed_match.group(2)
if "_eclasses_" not in d:
if "INHERITED" in d: