1 |
commit: c0ac477af61fa107aaececeda2ca888292719e17 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Aug 23 16:55:19 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 23 16:55:19 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c0ac477a |
7 |
|
8 |
read_corresponding_eapi_file: cache results |
9 |
|
10 |
--- |
11 |
pym/portage/package/ebuild/config.py | 3 ++- |
12 |
pym/portage/util/__init__.py | 7 +++++++ |
13 |
2 files changed, 9 insertions(+), 1 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
16 |
index 2fa799f..81e0501 100644 |
17 |
--- a/pym/portage/package/ebuild/config.py |
18 |
+++ b/pym/portage/package/ebuild/config.py |
19 |
@@ -42,7 +42,7 @@ from portage.repository.config import load_repository_config |
20 |
from portage.util import ensure_dirs, getconfig, grabdict, \ |
21 |
grabdict_package, grabfile, grabfile_package, LazyItemsDict, \ |
22 |
normalize_path, shlex_split, stack_dictlist, stack_dicts, stack_lists, \ |
23 |
- writemsg, writemsg_level |
24 |
+ writemsg, writemsg_level, _eapi_cache |
25 |
from portage.versions import catpkgsplit, catsplit, cpv_getkey, _pkg_str |
26 |
|
27 |
from portage.package.ebuild._config import special_env_vars |
28 |
@@ -811,6 +811,7 @@ class config(object): |
29 |
# and subsequent calls to the _init() functions have no effect. |
30 |
portage.output._init(config_root=self['PORTAGE_CONFIGROOT']) |
31 |
portage.data._init(self) |
32 |
+ _eapi_cache.clear() |
33 |
|
34 |
if mycpv: |
35 |
self.setcpv(mycpv) |
36 |
|
37 |
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py |
38 |
index 4645be5..951a158 100644 |
39 |
--- a/pym/portage/util/__init__.py |
40 |
+++ b/pym/portage/util/__init__.py |
41 |
@@ -379,6 +379,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): |
42 |
newdict[k] = " ".join(v) |
43 |
return newdict |
44 |
|
45 |
+_eapi_cache = {} |
46 |
+ |
47 |
def read_corresponding_eapi_file(filename): |
48 |
""" |
49 |
Read the 'eapi' file from the directory 'filename' is in. |
50 |
@@ -387,6 +389,10 @@ def read_corresponding_eapi_file(filename): |
51 |
default = "0" |
52 |
eapi_file = os.path.join(os.path.dirname(filename), "eapi") |
53 |
try: |
54 |
+ return _eapi_cache[eapi_file] |
55 |
+ except KeyError: |
56 |
+ pass |
57 |
+ try: |
58 |
f = io.open(_unicode_encode(eapi_file, |
59 |
encoding=_encodings['fs'], errors='strict'), |
60 |
mode='r', encoding=_encodings['repo.content'], errors='replace') |
61 |
@@ -401,6 +407,7 @@ def read_corresponding_eapi_file(filename): |
62 |
except IOError: |
63 |
eapi = default |
64 |
|
65 |
+ _eapi_cache[eapi_file] = eapi |
66 |
return eapi |
67 |
|
68 |
def grabdict_package(myfilename, juststrings=0, recursive=0, allow_wildcard=False, allow_repo=False, |