debian/bin/kconfig.py, debian/lib/python/debian_linux/kconfig.py: Cleanup.

svn path=/dists/trunk/linux-2.6/; revision=8985
This commit is contained in:
Bastian Blank 2007-06-17 11:09:00 +00:00
parent 33a2a4dbbd
commit f030ad5dbf
2 changed files with 12 additions and 21 deletions

View File

@ -1,14 +1,12 @@
#!/usr/bin/env python2.4
import optparse, os.path, sys
from debian_linux.abi import *
from debian_linux.config import *
from debian_linux.kconfig import *
def merge(output, *config):
config = [os.path.join('debian/arch', c) for c in config]
kconfig = kconfigfile()
kconfig = KconfigFile()
for c in config:
kconfig.read(file(c))
file(output, "w").write(str(kconfig))

View File

@ -1,33 +1,26 @@
__all__ = (
"kconfigfile",
"KconfigFile",
)
class _entry(object):
__slots__ = "name"
def __init__(self, name):
self.name = name
class _entry_string(_entry):
__slots__ = "value"
class EntryString(object):
__slots__ = "name", "value"
def __init__(self, name, value):
super(_entry_string, self).__init__(name)
self.name = name
self.value = value
def __str__(self):
return "CONFIG_%s=%s" % (self.name, self.value)
class _entry_tristate(_entry):
__slots__ = "value"
class EntryTristate(object):
__slots__ = "name", "value"
VALUE_NO = 0
VALUE_YES = 1
VALUE_MOD = 2
def __init__(self, name, value = None):
super(_entry_tristate, self).__init__(name)
self.name = name
if value == 'n' or value is None:
self.value = self.VALUE_NO
elif value == 'y':
@ -44,7 +37,7 @@ class _entry_tristate(_entry):
elif self.value == self.VALUE_MOD:
return "%s=m" % conf
class kconfigfile(dict):
class KconfigFile(dict):
def __str__(self):
ret = []
for i in self.str_iter():
@ -59,13 +52,13 @@ class kconfigfile(dict):
option = line[7:i]
value = line[i+1:]
if value in ('y', 'm'):
entry = _entry_tristate(option, value)
entry = EntryTristate(option, value)
else:
entry = _entry_string(option, value)
entry = EntryString(option, value)
self[option] = entry
elif line.startswith("# CONFIG_"):
option = line[9:-11]
self[option] = _entry_tristate(option)
self[option] = EntryTristate(option)
elif line.startswith("#") or not line:
pass
else: