summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-08-23 09:55:19 -0700
committerZac Medico <zmedico@gentoo.org>2012-08-23 09:55:19 -0700
commitc0ac477af61fa107aaececeda2ca888292719e17 (patch)
treea6d9b5f0026dd797d26861d1b24d5c68ecb2306e /pym
parent5335ccb6558f22ddc926714dcba4443cc7333b6a (diff)
downloadportage-c0ac477af61fa107aaececeda2ca888292719e17.tar.gz
portage-c0ac477af61fa107aaececeda2ca888292719e17.tar.bz2
portage-c0ac477af61fa107aaececeda2ca888292719e17.zip
read_corresponding_eapi_file: cache results
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/package/ebuild/config.py3
-rw-r--r--pym/portage/util/__init__.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 2fa799f7e..81e05012e 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -42,7 +42,7 @@ from portage.repository.config import load_repository_config
from portage.util import ensure_dirs, getconfig, grabdict, \
grabdict_package, grabfile, grabfile_package, LazyItemsDict, \
normalize_path, shlex_split, stack_dictlist, stack_dicts, stack_lists, \
- writemsg, writemsg_level
+ writemsg, writemsg_level, _eapi_cache
from portage.versions import catpkgsplit, catsplit, cpv_getkey, _pkg_str
from portage.package.ebuild._config import special_env_vars
@@ -811,6 +811,7 @@ class config(object):
# and subsequent calls to the _init() functions have no effect.
portage.output._init(config_root=self['PORTAGE_CONFIGROOT'])
portage.data._init(self)
+ _eapi_cache.clear()
if mycpv:
self.setcpv(mycpv)
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 4645be52f..951a158a9 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -379,6 +379,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
newdict[k] = " ".join(v)
return newdict
+_eapi_cache = {}
+
def read_corresponding_eapi_file(filename):
"""
Read the 'eapi' file from the directory 'filename' is in.
@@ -387,6 +389,10 @@ def read_corresponding_eapi_file(filename):
default = "0"
eapi_file = os.path.join(os.path.dirname(filename), "eapi")
try:
+ return _eapi_cache[eapi_file]
+ except KeyError:
+ pass
+ try:
f = io.open(_unicode_encode(eapi_file,
encoding=_encodings['fs'], errors='strict'),
mode='r', encoding=_encodings['repo.content'], errors='replace')
@@ -401,6 +407,7 @@ def read_corresponding_eapi_file(filename):
except IOError:
eapi = default
+ _eapi_cache[eapi_file] = eapi
return eapi
def grabdict_package(myfilename, juststrings=0, recursive=0, allow_wildcard=False, allow_repo=False,