[kernel-team] 02/86: kconfigeditor/kconfig/menu/file.py: Update.
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Mon Dec 21 00:34:52 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 fcc98376dbcde79763ccb4b3195ff8c2862e2e7d
Author: Bastian Blank <waldi at debian.org>
Date: Tue Mar 11 13:59:36 2008 +0000
kconfigeditor/kconfig/menu/file.py: Update.
svn path=/people/waldi/utils/kconfigeditor2/; revision=10784
---
.../kconfigeditor/kconfig/menu/file.py | 65 +++++++++++++++-------
1 file changed, 44 insertions(+), 21 deletions(-)
diff --git a/utils/kconfigeditor2/kconfigeditor/kconfig/menu/file.py b/utils/kconfigeditor2/kconfigeditor/kconfig/menu/file.py
index 551d2ec..ea97735 100644
--- a/utils/kconfigeditor2/kconfigeditor/kconfig/menu/file.py
+++ b/utils/kconfigeditor2/kconfigeditor/kconfig/menu/file.py
@@ -1,27 +1,33 @@
import re
-class File(object):
- pass
+class File(list):
+ def __init__(self, filename):
+ self.filename = filename
+
+class FileConfig(object):
+ def __init__(self, name):
+ self.name = name
+
+ def __repr__(self):
+ return "<%s(%s)>" % (self.__class__.__name__, self.name)
class _Parser(object):
- def __call__(self, fd):
+ def __call__(self, filename):
lineno = 0
stack = _Stack()
- _BlockRoot(stack)
+ _BlockRoot(stack, File(filename))
- for line in fd:
+ for line in file(filename):
line = line.rstrip()
if not line:
stack.top().process_line_empty()
elif line.lstrip()[0] == '#':
pass
else:
- print stack._list
- print line
stack.top().process_line(line)
lineno += 1
- stack.top().stop(lineno, 0)
+ return stack.top().stop(lineno, 0)
class _Text(object):
__slots__ = "text", "lineno", "column"
@@ -63,6 +69,9 @@ class _Stack(object):
return self._list[-1]
class _Element(object):
+ entry = None
+ stack = None
+
def __init__(self, parent):
self.stack = parent.stack
self.stack.push(self)
@@ -76,7 +85,7 @@ class _Element(object):
def recurse(self, name, *args):
self.pop()
- getattr(self.stack.top(), name)(*args)
+ return getattr(self.stack.top(), name)(*args)
class _BlockContainer(object):
split_rules = r"""
@@ -97,7 +106,6 @@ $"""
if not match:
raise Exception, "Can't parse: '%s'" % text
rest = match.group('rest1') or match.group('rest2')
- print "rest:", rest
getattr(self, "process_%s" % match.group('word'))(rest, match.group('ind'))
def process_line_empty(self):
@@ -112,13 +120,13 @@ class _BlockContainerCommon(_BlockContainer):
_BlockComment(self)
def process_config(self, text, ind):
- _BlockConfig(self)
+ _BlockConfig(self, text)
def process_if(self, text, ind):
- _BlockIf(self)
+ _BlockIf(self, text)
def process_menuconfig(self, text, ind):
- _BlockMenuconfig(self, ind)
+ _BlockMenuconfig(self, text)
def process_source(self, text, ind):
pass
@@ -134,7 +142,7 @@ class _BlockContainerMenu(_BlockContainer):
class _BlockObject(_Element):
def __getattr__(self, name):
def ret(*args):
- self.recurse(name, *args)
+ return self.recurse(name, *args)
return ret
class _BlockObjectIndentation(_BlockObject):
@@ -161,8 +169,8 @@ class _BlockRoot(
_BlockContainerCommon,
_BlockContainerMenu,
):
- def __init__(self, stack):
- self.stack = stack
+ def __init__(self, stack, entry):
+ self.stack, self.entry = stack, entry
stack.push(self)
def __getattr__(self, name):
@@ -173,11 +181,13 @@ class _BlockRoot(
def stop(self, lineno, column):
self.stack.pop(self)
+ return self.entry
class _BlockChoice(_BlockObject, _BlockContainerCommon):
def __init__(self, parent):
super(_BlockChoice, self).__init__(parent)
- _BlockConfig(self)
+ self.entry = parent.entry
+ _BlockConfigData(self)
def process_default(self, text, ind):
_BlockType(self, text, ind)
@@ -188,7 +198,7 @@ class _BlockChoice(_BlockObject, _BlockContainerCommon):
class _BlockComment(_BlockObject, _BlockContainerDepends):
pass
-class _BlockConfig(_BlockObject, _BlockContainerDepends):
+class _BlockConfigData(_BlockObject, _BlockContainerDepends):
def process_bool(self, text, ind):
_BlockType(self, text, ind)
@@ -233,6 +243,12 @@ class _BlockConfig(_BlockObject, _BlockContainerDepends):
def process_tristate(self, text, ind):
_BlockType(self, text, ind)
+class _BlockConfig(_BlockConfigData):
+ def __init__(self, parent, name):
+ super(_BlockConfig, self).__init__(parent)
+ self.entry = FileConfig(name)
+ parent.entry.append(self.entry)
+
class _BlockDepends(_BlockObjectIndentation):
pass
@@ -244,6 +260,9 @@ class _BlockIf(_BlockObject,
_BlockContainerCommon,
_BlockContainerMenu,
):
+ def __init__(self, parent, name):
+ super(_BlockIf, self).__init__(parent)
+ self.entry = parent.entry
def process_endif(self, text, ind):
self.pop()
@@ -255,7 +274,8 @@ class _BlockMenu(_BlockObject,
):
def __init__(self, parent, text):
super(_BlockMenu, self).__init__(parent)
- pass
+ # TODO
+ self.entry = parent.entry
def process_depends(self, text, ind):
pass
@@ -263,8 +283,11 @@ class _BlockMenu(_BlockObject,
def process_endmenu(self, text, ind):
self.pop()
-class _BlockMenuconfig(_BlockConfig, _BlockMenu):
- pass
+class _BlockMenuconfig(_BlockMenu):
+ def __init__(self, parent, name):
+ super(_BlockMenuconfig, self).__init__(parent, "")
+ self.entry = parent.entry
+ _BlockConfigData(self)
class _BlockType(_BlockObject):
def __init__(self, parent, text, ind):
--
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