* debian/lib/python/debian_linux/config.py: Split config_reader.
* debian/lib/python/debian_linux/gencontrol.py: Use config_reader_arch. svn path=/dists/trunk/linux-2.6/; revision=6700
This commit is contained in:
parent
aa9b0d8727
commit
78c1da5137
|
@ -3,15 +3,12 @@ import os, os.path, re, sys, textwrap, ConfigParser
|
|||
__all__ = [
|
||||
'config_parser',
|
||||
'config_reader',
|
||||
'config_reader_arch',
|
||||
]
|
||||
|
||||
_marker = object()
|
||||
|
||||
class config_reader(dict):
|
||||
"""
|
||||
Read configs in debian/arch and in the underlay directory.
|
||||
"""
|
||||
|
||||
class schema_item_boolean(object):
|
||||
def __call__(self, i):
|
||||
i = i.strip().lower()
|
||||
|
@ -52,6 +49,33 @@ class config_reader(dict):
|
|||
def _get_files(self, name):
|
||||
return [os.path.join(i, name) for i in self._dirs if i]
|
||||
|
||||
def _update(self, ret, inputkey):
|
||||
for key, value in super(config_reader, self).get(tuple(inputkey), {}).iteritems():
|
||||
ret[key] = value
|
||||
|
||||
def get(self, key, default = _marker):
|
||||
if isinstance(key, basestring):
|
||||
key = key,
|
||||
|
||||
ret = super(config_reader, self).get(tuple(key), default)
|
||||
if ret == _marker:
|
||||
raise KeyError, key
|
||||
return ret
|
||||
|
||||
def merge(self, section, *args):
|
||||
ret = {}
|
||||
for i in xrange(0, len(args) + 1):
|
||||
ret.update(self.get(tuple([section] + list(args[:i])), {}))
|
||||
return ret
|
||||
|
||||
def sections(self):
|
||||
return super(config_reader, self).keys()
|
||||
|
||||
class config_reader_arch(config_reader):
|
||||
def __init__(self, dirs = []):
|
||||
super(config_reader_arch, self).__init__(dirs)
|
||||
self._read_base()
|
||||
|
||||
def _read_arch(self, arch):
|
||||
files = self._get_files("%s/%s" % (arch, self.config_name))
|
||||
config = config_parser(self.schema, files)
|
||||
|
@ -143,28 +167,6 @@ class config_reader(dict):
|
|||
for flavour in flavours:
|
||||
self._read_flavour(arch, subarch, flavour)
|
||||
|
||||
def _update(self, ret, inputkey):
|
||||
for key, value in super(config_reader, self).get(tuple(inputkey), {}).iteritems():
|
||||
ret[key] = value
|
||||
|
||||
def get(self, key, default = _marker):
|
||||
if isinstance(key, basestring):
|
||||
key = key,
|
||||
|
||||
ret = super(config_reader, self).get(tuple(key), default)
|
||||
if ret == _marker:
|
||||
raise KeyError, key
|
||||
return ret
|
||||
|
||||
def merge(self, section, *args):
|
||||
ret = {}
|
||||
for i in xrange(0, len(args) + 1):
|
||||
ret.update(self.get(tuple([section] + list(args[:i])), {}))
|
||||
return ret
|
||||
|
||||
def sections(self):
|
||||
return super(config_reader, self).keys()
|
||||
|
||||
class config_parser(object):
|
||||
__slots__ = 'configs', 'schema'
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class gencontrol(object):
|
|||
makefile_targets = ('binary-arch', 'build', 'setup', 'source')
|
||||
|
||||
def __init__(self, underlay = None):
|
||||
self.config = config_reader([underlay, "debian/arch"])
|
||||
self.config = config_reader_arch([underlay, "debian/arch"])
|
||||
self.templates = templates()
|
||||
|
||||
def __call__(self):
|
||||
|
|
Loading…
Reference in New Issue