[kernel-team] 37/86: lib/kconfigeditor/kconfig/package/files.py: Support per-option comments.
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Mon Dec 21 00:34:56 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 5c5a8014761e9e7098ad415261a51525594832f2
Author: Bastian Blank <waldi at debian.org>
Date: Fri Mar 14 19:47:00 2008 +0000
lib/kconfigeditor/kconfig/package/files.py: Support per-option comments.
svn path=/people/waldi/utils/kconfigeditor2/; revision=10863
---
.../lib/kconfigeditor/kconfig/package/files.py | 46 ++++++++++++++++------
1 file changed, 34 insertions(+), 12 deletions(-)
diff --git a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/package/files.py b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/package/files.py
index 6ddcbe1..8c1b3ec 100644
--- a/utils/kconfigeditor2/lib/kconfigeditor/kconfig/package/files.py
+++ b/utils/kconfigeditor2/lib/kconfigeditor/kconfig/package/files.py
@@ -134,7 +134,7 @@ class File(dict):
ignored.add(i.name)
return []
processed.add(i.name)
- return [e]
+ return e.dump()
def _dump_file(self, processed, ignored, have_prompt, f):
ret = []
@@ -206,46 +206,68 @@ class File(dict):
fd.write(str(i) + "\n")
def read(self, f):
+ comments = []
+
for line in iter(f.readlines()):
line = line.strip()
+
if line.startswith("CONFIG_"):
i = line.find('=')
option = line[7:i]
value = line[i+1:]
if value in ('y', 'm', 'n'):
- entry = FileEntryTristate(option, value)
+ entry = FileEntryTristate(option, value, comments)
else:
- entry = FileEntryString(option, value)
+ entry = FileEntryString(option, value, comments)
self[option] = entry
+ comments = []
+
elif line.startswith("# CONFIG_"):
option = line[9:-11]
- self[option] = FileEntryTristate(option)
+ self[option] = FileEntryTristate(option, 'n', comments)
+ comments = []
+
+ elif line.startswith("#. "):
+ comments.append(line[3:])
+
elif line.startswith("#") or not line:
pass
+
else:
raise RuntimeError, "Can't recognize %s" % line
+class FileEntry(object):
+ __slots__ = "name", "comments"
+
+ def __init__(self, name, comments):
+ self.name, self.comments = name, comments
+
+ def dump(self):
+ ret = ["#. %s" % i for i in self.comments]
+ ret.append(str(self))
+ return ret
+
# TODO
-class FileEntryString(object):
- __slots__ = "name", "value"
+class FileEntryString(FileEntry):
+ __slots__ = "value"
- def __init__(self, name, value):
- self.name = name
+ def __init__(self, name, value, comments):
+ super(FileEntryString, self).__init__(name, comments)
self.value = value
def __str__(self):
return "CONFIG_%s=%s" % (self.name, self.value)
# TODO
-class FileEntryTristate(object):
- __slots__ = "name", "value"
+class FileEntryTristate(FileEntry):
+ __slots__ = "name", "value", "comments"
VALUE_NO = 0
VALUE_YES = 1
VALUE_MOD = 2
- def __init__(self, name, value = None):
- self.name = name
+ def __init__(self, name, value, comments):
+ super(FileEntryTristate, self).__init__(name, comments)
if value == 'n' or value is None:
self.value = self.VALUE_NO
elif value == 'y':
--
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