[kernel] r13136 - people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig
Bastian Blank
waldi at alioth.debian.org
Mon Mar 16 21:12:45 UTC 2009
Author: waldi
Date: Mon Mar 16 21:12:43 2009
New Revision: 13136
Log:
Cleanup visible entry handling.
Modified:
people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/config.py
Modified: people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/config.py
==============================================================================
--- people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/config.py (original)
+++ people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/config.py Mon Mar 16 21:12:43 2009
@@ -11,12 +11,12 @@
self.read(fd)
- def _dump_file_choice(self, processed, ignored, have_prompt, f):
+ def _dump_file_choice(self, processed, ignored, visible, f):
ret = []
nr = 0
for i in f:
if isinstance(i, MenuEntryConfig):
- r = self._dump_file_config(processed, ignored, have_prompt, i)
+ r = self._dump_file_config(processed, ignored, visible, i)
if r:
ret.extend(r)
nr += 1
@@ -29,7 +29,7 @@
ret.append('## end choice')
return ret
- def _dump_file_config(self, processed, ignored, have_prompt, i):
+ def _dump_file_config(self, processed, ignored, visible, i):
e = self.get(i.name, None)
if e is None:
return []
@@ -37,7 +37,7 @@
if i.name in processed:
return []
if not i.prompt:
- if i.name in have_prompt:
+ if i.name in visible:
return []
if ignored is not None:
ignored.add(i.name)
@@ -45,32 +45,34 @@
processed.add(i.name)
return e.dump(i)
- def _dump_file(self, processed, ignored, have_prompt, f):
+ def _dump_file(self, processed, ignored, visible, f):
ret = []
for i in f:
if isinstance(i, MenuEntryConfig):
- ret.extend(self._dump_file_config(processed, ignored, have_prompt, i))
+ ret.extend(self._dump_file_config(processed, ignored, visible, i))
elif isinstance(i, MenuEntryChoice):
- ret.extend(self._dump_file_choice(processed, ignored, have_prompt, i))
+ ret.extend(self._dump_file_choice(processed, ignored, visible, i))
if ret:
ret[0:0] = ["##", "## file: %s" % f.filename, "##"]
ret.append('')
return ret
- def _dump_prompt_file_config(self, have_prompt, i):
- e = self.get(i.name, None)
- if e is not None:
- if i.prompt:
- have_prompt.add(i.name)
+ def _write_check_visible(self, menufiles):
+ ret = set()
- def _dump_prompt_file(self, have_prompt, f):
- for i in f:
- if isinstance(i, MenuEntryConfig):
- self._dump_prompt_file_config(have_prompt, i)
- elif isinstance(i, MenuEntryChoice):
- for i1 in i:
- if isinstance(i1, MenuEntryConfig):
- self._dump_prompt_file_config(have_prompt, i1)
+ def flatten():
+ for file in menufiles:
+ for entry in file:
+ if isinstance(entry, MenuEntryConfig):
+ yield entry
+ elif isinstance(entry, MenuEntryChoice):
+ for i in entry:
+ yield i
+
+ for menuentry in flatten():
+ entry = self.get(menuentry.name)
+ if entry and menuentry.prompt:
+ visible.add(menuentry.name)
def write(self, fd, menufiles, ignore_silent=False):
def menufiles_cmp_key(entry):
@@ -83,9 +85,7 @@
menufiles.sort(key=menufiles_cmp_key)
- have_prompt = set()
- for f in menufiles:
- self._dump_prompt_file(have_prompt, f)
+ visible = self.__write_check_visible(menufiles)
ret = []
processed = set()
@@ -93,7 +93,7 @@
if not ignore_silent:
ignored_sub = None
for f in menufiles:
- ret.extend(self._dump_file(processed, ignored_sub, have_prompt, f))
+ ret.extend(self._dump_file(processed, ignored_sub, visible, f))
s = set(self.keys())
unprocessed = s - processed - ignored
More information about the Kernel-svn-changes
mailing list