Author: waldi Date: Tue Mar 11 16:57:06 2008 New Revision: 10804 Log: lib/kconfigeditor/kconfig/menu/file.py: Update.
Modified: people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py Modified: people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py ============================================================================== --- people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py (original) +++ people/waldi/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py Tue Mar 11 16:57:06 2008 @@ -52,7 +52,7 @@ else: stack.top().process_line(line) lineno += 1 - return stack.top().stop(lineno, 0) + return stack.top().process_stop(lineno, 0) class _Text(object): __slots__ = "text", "lineno", "column" @@ -116,7 +116,7 @@ split_rules = r""" ^ (?P<ind>\s*) - (---)?(?P<word>[a-z_]+)(---)? + (---\s*)?(?P<word>[a-z_]+)(\s*---)? ( \s*"(?P<rest2>.+)" | @@ -158,7 +158,7 @@ class _BlockContainerDepends(_BlockContainer): def process_depends(self, text, ind): - _BlockDepends(self, ind) + _BlockType(self, text, ind) class _BlockContainerMenu(_BlockContainer): def process_menu(self, text, ind): @@ -166,28 +166,11 @@ class _BlockObject(_Element): def __getattr__(self, name): - def ret(*args): - return self.recurse(name, *args) - return ret - -class _BlockObjectIndentation(_BlockObject): - split_rules = r"^(?P<ind>\s+)(?P<rest>.*)$" - split_re = re.compile(split_rules) - - def __init__(self, parent, ind): - super(_BlockObjectIndentation, self).__init__(parent) - self._indentation = ind - - def process_line(self, text): - match = self.split_re.match(text) - if not match: - return self.recurse('process_line', text) - l = len(match.group('ind')) - if self._indentation < l: - return self.recurse('process_line', text) - - def process_line_empty(self): - pass + if name.startswith('process_'): + def ret(*args): + return self.recurse(name, *args) + return ret + raise AttributeError(name) class _BlockRoot( _BlockContainerChoice, @@ -204,13 +187,14 @@ def process_mainmenu(self, text, ind): pass - def stop(self, lineno, column): + def process_stop(self, lineno, column): self.stack.pop(self) return self.entry class _BlockChoice(_BlockObject, _BlockContainerCommon): def __init__(self, parent): super(_BlockChoice, self).__init__(parent) + # TODO self.entry = parent.entry _BlockConfigData(self) @@ -274,11 +258,32 @@ self.entry = FileConfig(name) parent.entry.append(self.entry) -class _BlockDepends(_BlockObjectIndentation): - pass +class _BlockHelp(_BlockObject): + split_rules = r"^(?P<ind>\s+)(?P<rest>.*)$" + split_re = re.compile(split_rules) + + def __init__(self, parent, ind): + super(_BlockHelp, self).__init__(parent) + self.indentation_init = len(ind) + self.indentation = None + + def process_line(self, text): + match = self.split_re.match(text) + if match: + ind = match.group('ind').expandtabs() + l = len(ind) + if l >= self.indentation_init: + if self.indentation is None: + self.indentation = l + return + elif l >= self.indentation: + return + + return self.recurse('process_line', text) + + def process_line_empty(self): + pass -class _BlockHelp(_BlockObjectIndentation): - pass class _BlockIf(_BlockObject, _BlockContainerChoice, @@ -312,6 +317,9 @@ def __init__(self, parent, name): super(_BlockMenuconfig, self).__init__(parent, "") self.entry = parent.entry + # TODO + entry = FileConfig(name) + parent.entry.append(entry) _BlockConfigData(self) class _BlockSource(_BlockObject): _______________________________________________ Kernel-svn-changes mailing list Kernel-svn-changes@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/kernel-svn-changes