diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-10-01 16:24:49 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-10-01 16:24:49 +0100 |
commit | 32f48e4ebd0f8855c123cf8f28459966566e7a2d (patch) | |
tree | 2ee72cc1fdf13b34baf12d2a4f122230f307bef2 | |
parent | 3951387f3e8840abc779eb2ec1085b7c195710bc (diff) | |
download | lorry-controller-32f48e4ebd0f8855c123cf8f28459966566e7a2d.tar.gz |
Support prefix in lorries stanza
-rw-r--r-- | lorrycontroller/confparser.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lorrycontroller/confparser.py b/lorrycontroller/confparser.py index 6f18de6..d2f9402 100644 --- a/lorrycontroller/confparser.py +++ b/lorrycontroller/confparser.py @@ -92,6 +92,10 @@ class LorryControllerConfig(object): '''Validate a 'lorries' stanza.''' if type(entry.get('globs', None)) != list: self._give_up("Lorries stanzas need lists for their 'globs'") + if entry.get('prefix', None) is None: + entry['prefix'] = u"" + if type(entry['prefix']) != unicode: + self._give_up("Lorry prefixes should be strings.") my_lorries = set() git_base = os.path.join(self.settings['work-area'], 'git') for glob_entry in entry['globs']: @@ -112,9 +116,11 @@ class LorryControllerConfig(object): with open(lorry, "r") as fh: lorry_json = json.load(fh) for name, content in lorry_json.iteritems(): - if self.lorries.get(name, None) is not None: - self._give_up("Lorry repeated: %s" % name) - self.lorries[name] = content + fullname = os.path.join(entry['prefix'], name) + if self.lorries.get(fullname, None) is not None: + self._give_up("Lorry repeated: %s" % fullname) + logging.debug("[%r]=%r" % (fullname, content)) + self.lorries[fullname] = content except Exception, e: logging.debug("Unable to parse %s, because of %s. Moving on" % (lorry, e)) |