[kernel-team] 11/86: lib/kconfigeditor/kconfig/menu/file.py - Parse '-enclosed strings correctly. - End text correctly.
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Mon Dec 21 00:34:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch benh/kconfigeditor2
in repository kernel-team.
commit 402b5ece1ffe89d06c0586156108eb88a4f7ea62
Author: Bastian Blank <waldi at debian.org>
Date: Tue Mar 11 17:39:58 2008 +0000
lib/kconfigeditor/kconfig/menu/file.py
- Parse '-enclosed strings correctly.
- End text correctly.
svn path=/people/waldi/utils/kconfigeditor2/; revision=10806
---
.../lib/kconfigeditor/kconfig/menu/file.py | 88 +++++++++++++---------
1 file changed, 51 insertions(+), 37 deletions(-)
diff --git a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
index 2f7650e..8bd84bc 100644
--- a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
+++ b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/menu/file.py
@@ -4,37 +4,20 @@ class File(list):
def __init__(self, filename):
self.filename = filename
- def __lt__(self, other):
- return self.filename < other.filename
-
- def __le__(self, other):
- return self.filename <= other.filename
-
- def __eq__(self, other):
- return self.filename == other.filename
-
- def __ne__(self, other):
- return self.filename != other.filename
-
- def __gt__(self, other):
- return self.filename > other.filename
-
- def __ge__(self, other):
- return self.filename >= other.filename
-
class FileConfig(object):
def __init__(self, name):
self.name = name
+ self.prompt = None
def __repr__(self):
- return "<%s(%s)>" % (self.__class__.__name__, self.name)
+ return "<%s(%r, %r)>" % (self.__class__.__name__, self.name, self.prompt)
class FileSource(object):
def __init__(self, filename):
self.filename = filename
def __repr__(self):
- return "<%s(%s)>" % (self.__class__.__name__, self.filename)
+ return "<%s(%r)>" % (self.__class__.__name__, self.filename)
class Parser(object):
def __call__(self, fd, filename):
@@ -50,6 +33,8 @@ class Parser(object):
elif line.lstrip()[0] == '#':
pass
else:
+ print line
+ print stack._list
stack.top().process_line(line)
lineno += 1
return stack.top().process_stop(lineno, 0)
@@ -118,7 +103,7 @@ class _BlockContainer(object):
(?P<ind>\s*)
(---\s*)?(?P<word>[a-z_]+)(\s*---)?
(
- \s*"(?P<rest2>.+)"
+ \s*(?P<rest2>["'].+)
|
\s+(?P<rest1>.+)
)?
@@ -154,6 +139,7 @@ class _BlockContainerCommon(_BlockContainer):
_BlockMenuconfig(self, text)
def process_source(self, text, ind):
+ text = text.strip('"')
_BlockSource(self, text)
class _BlockContainerDepends(_BlockContainer):
@@ -196,7 +182,7 @@ class _BlockChoice(_BlockObject, _BlockContainerCommon):
super(_BlockChoice, self).__init__(parent)
# TODO
self.entry = parent.entry
- _BlockConfigData(self)
+ _BlockConfigData(self, FileConfig(None))
def process_default(self, text, ind):
_BlockType(self, text, ind)
@@ -208,8 +194,37 @@ class _BlockComment(_BlockObject, _BlockContainerDepends):
pass
class _BlockConfigData(_BlockObject, _BlockContainerDepends):
+ _prompt_rules = r"""
+^
+ (
+ "(?P<text1>[^"]*)"
+ |
+ '(?P<text2>[^']*)'
+ )
+ (
+ \s*
+ if
+ \s+
+ (?P<expression>.*)
+ )?
+$"""
+ _prompt_re = re.compile(_prompt_rules, re.X)
+
+ def __init__(self, parent, entry):
+ super(_BlockConfigData, self).__init__(parent)
+ self.entry = entry
+
+ def _process_prompt(self, text, ind):
+ if text is not None:
+ match = self._prompt_re.match(text)
+ if match:
+ self.entry.prompt = match.group('text1') or match.group('text2')
+ text = match.group('expression')
+ _BlockType(self, text, ind)
+
def process_bool(self, text, ind):
- _BlockType(self, text, ind)
+ # TODO
+ self._process_prompt(text, ind)
process_boolean = process_bool
@@ -226,10 +241,12 @@ class _BlockConfigData(_BlockObject, _BlockContainerDepends):
_BlockHelp(self, ind)
def process_hex(self, text, ind):
- _BlockType(self, text, ind)
+ # TODO
+ self._process_prompt(text, ind)
def process_int(self, text, ind):
- _BlockType(self, text, ind)
+ # TODO
+ self._process_prompt(text, ind)
def process_option(self, text, ind):
_BlockType(self, text, ind)
@@ -238,7 +255,7 @@ class _BlockConfigData(_BlockObject, _BlockContainerDepends):
pass
def process_prompt(self, text, ind):
- pass
+ self._process_prompt(text, ind)
def process_range(self, text, ind):
_BlockType(self, text, ind)
@@ -247,15 +264,16 @@ class _BlockConfigData(_BlockObject, _BlockContainerDepends):
_BlockType(self, text, ind)
def process_string(self, text, ind):
- _BlockType(self, text, ind)
+ # TODO
+ self._process_prompt(text, ind)
def process_tristate(self, text, ind):
- _BlockType(self, text, ind)
+ # TODO
+ self._process_prompt(text, ind)
class _BlockConfig(_BlockConfigData):
def __init__(self, parent, name):
- super(_BlockConfig, self).__init__(parent)
- self.entry = FileConfig(name)
+ super(_BlockConfig, self).__init__(parent, FileConfig(name))
parent.entry.append(self.entry)
class _BlockHelp(_BlockObject):
@@ -320,7 +338,7 @@ class _BlockMenuconfig(_BlockMenu):
# TODO
entry = FileConfig(name)
parent.entry.append(entry)
- _BlockConfigData(self)
+ _BlockConfigData(self, entry)
class _BlockSource(_BlockObject):
def __init__(self, parent, text):
@@ -331,13 +349,9 @@ class _BlockSource(_BlockObject):
class _BlockType(_BlockObject):
def __init__(self, parent, text, ind):
super(_BlockType, self).__init__(parent)
- self.nextline = True
self.process_line(text)
def process_line(self, text):
- if self.nextline:
- if not text or not text.endswith('\\'):
- self.nextline = False
- else:
- return self.recurse('process_line', text)
+ if not text or not text.endswith('\\'):
+ self.pop()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/kernel-team.git
More information about the Kernel-svn-changes
mailing list