Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/
Date: Tue, 01 Apr 2014 16:38:52
Message-Id: 1396280357.c8a9eee2bc05ec7c02110318277cc0604c69ad44.dywi@gentoo
1 commit: c8a9eee2bc05ec7c02110318277cc0604c69ad44
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Mon Mar 31 15:39:17 2014 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Mon Mar 31 15:39:17 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=c8a9eee2
7
8 config/entryutil: iter_entries_with_value_type()
9
10 ---
11 roverlay/config/entryutil.py | 30 +++++++++++++++++++++++++-----
12 1 file changed, 25 insertions(+), 5 deletions(-)
13
14 diff --git a/roverlay/config/entryutil.py b/roverlay/config/entryutil.py
15 index 716c166..899bd4d 100644
16 --- a/roverlay/config/entryutil.py
17 +++ b/roverlay/config/entryutil.py
18 @@ -65,6 +65,29 @@ def find_config_path ( name ):
19 raise roverlay.config.exceptions.ConfigOptionNotFound ( name )
20 # --- end of find_config_path (...) ---
21
22 +def iter_visible_entries():
23 + for entry_key, entry in CONFIG_ENTRY_MAP.items():
24 + if entry is not None:
25 + # else entry is disabled
26 + yield ( entry_key, entry )
27 +# --- end of iter_visible_entries (...) ---
28 +
29 +def iter_entries_with_value_type ( value_types ):
30 + for key, entry in iter_visible_entries():
31 + if isinstance ( entry, dict ):
32 + if entry.get ( 'value_type' ) in value_types:
33 + yield ( key, entry )
34 + elif entry and isinstance ( entry, str ):
35 + # ^ not really necessary
36 + real_key, real_entry = deref_entry_safe ( key )
37 + if (
38 + isinstance ( real_entry, dict )
39 + and real_entry.get ( 'value_type' ) in value_types
40 + ):
41 + yield ( key, real_entry )
42 + # -- end for
43 +# --- end of iter_entries_with_value_type (...) ---
44 +
45 def iter_config_keys():
46 for key, entry in CONFIG_ENTRY_MAP.items():
47 if isinstance ( entry, dict ):
48 @@ -75,12 +98,9 @@ def _iter_entries():
49 """Iterates through all entries in CONFIG_ENTRY_MAP and yields config
50 entry information (entry name, description).
51 """
52 - for entry_key, entry in CONFIG_ENTRY_MAP.items():
53 + for entry_key, entry in iter_visible_entries():
54 name = entry_key.upper()
55 - if entry is None:
56 - # entry is disabled
57 - pass
58 - elif isinstance ( entry, dict ):
59 + if isinstance ( entry, dict ):
60 description = entry.get ( 'description' ) or entry.get ( 'desc' )
61 if description:
62 if isinstance ( description, str ):