From c0ac477af61fa107aaececeda2ca888292719e17 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 23 Aug 2012 09:55:19 -0700 Subject: read_corresponding_eapi_file: cache results --- pym/portage/package/ebuild/config.py | 3 ++- pym/portage/util/__init__.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'pym') 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. @@ -386,6 +388,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'), @@ -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, -- cgit v1.2.3-1-g7c22