diff options
author | Bastian Blank <waldi@debian.org> | 2007-08-15 14:29:58 +0000 |
---|---|---|
committer | Bastian Blank <waldi@debian.org> | 2007-08-15 14:29:58 +0000 |
commit | 5f0d29bcd939d2f09b6e002287082ee83a7deba6 (patch) | |
tree | 78daa5bc9f6f22529c5be900dfa1d1f6f32b574c | |
parent | 21ec8f8e00992fc44994c7f3d873778e7a4d6bed (diff) | |
download | kernel_replicant_linux-5f0d29bcd939d2f09b6e002287082ee83a7deba6.tar.gz kernel_replicant_linux-5f0d29bcd939d2f09b6e002287082ee83a7deba6.tar.bz2 kernel_replicant_linux-5f0d29bcd939d2f09b6e002287082ee83a7deba6.zip |
* debian/lib/python/debian_linux/gencontrol.py:
Expect config and template dirs as list and set default.
* debian/lib/python/debian_linux/utils.py:
Read templates from a list of directories.
svn path=/dists/trunk/linux-2.6/; revision=9305
-rw-r--r-- | debian/lib/python/debian_linux/gencontrol.py | 6 | ||||
-rw-r--r-- | debian/lib/python/debian_linux/utils.py | 29 |
2 files changed, 19 insertions, 16 deletions
diff --git a/debian/lib/python/debian_linux/gencontrol.py b/debian/lib/python/debian_linux/gencontrol.py index 2a2037d96059..e7b2ee383a01 100644 --- a/debian/lib/python/debian_linux/gencontrol.py +++ b/debian/lib/python/debian_linux/gencontrol.py @@ -24,9 +24,9 @@ class MakeFlags(dict): class Gencontrol(object): makefile_targets = ('binary-arch', 'build', 'setup', 'source') - def __init__(self, underlay = None): - self.config = ConfigReaderCore([underlay, "debian/config"]) - self.templates = Templates() + def __init__(self, config_dirs = ["debian/config"], template_dirs = ["debian/templates"]): + self.config = ConfigReaderCore(config_dirs) + self.templates = Templates(template_dirs) def __call__(self): packages = PackagesList() diff --git a/debian/lib/python/debian_linux/utils.py b/debian/lib/python/debian_linux/utils.py index f41233c5c558..abe46b7b3d40 100644 --- a/debian/lib/python/debian_linux/utils.py +++ b/debian/lib/python/debian_linux/utils.py @@ -1,4 +1,4 @@ -import debian, re, textwrap +import debian, re, os, textwrap class SortedDict(dict): __slots__ = '_list', @@ -32,30 +32,33 @@ class SortedDict(dict): yield self[i] class Templates(dict): - def __init__(self, dir = "debian/templates"): - self.dir = dir + def __init__(self, dirs = ["debian/templates"]): + self.dirs = dirs def __getitem__(self, key): try: - return dict.__getitem__(self, key) + return super(Templates, self).__getitem__(key) except KeyError: pass - ret = self._read(key) - dict.__setitem__(self, key, ret) - return ret + value = self._read(key) + super(Templates, self).__setitem__(key, value) + return value def __setitem__(self, key, value): raise NotImplemented() def _read(self, name): prefix, id = name.split('.', 1) - f = file("%s/%s.in" % (self.dir, name)) - if prefix == 'control': - return self._readControl(f) + for dir in self.dirs: + filename = "%s/%s.in" % (dir, name) + if os.path.exists(filename): + f = file(filename) + if prefix == 'control': + return self._read_control(f) + return f.read() + raise KeyError(name) - return f.read() - - def _readControl(self, f): + def _read_control(self, f): entries = [] while True: |