def configure(self, configuration, namespace=None): if isinstance(configuration, basestring): configuration = Format.read(configuration, quiet=True) if not configuration: return if namespace: try: configuration = configuration['namespace'][namespace] except KeyError: return else: if not configuration: return includes = configuration.pop('include', None) recursive_merge(self.configuration, configuration) if includes: for item in includes: if isinstance(item, dict): for namespace, pattern in item.iteritems(): for include in sorted(glob(pattern)): self.configure(include, namespace=namespace) else: for include in sorted(glob(item)): self.configure(include) return self
def configure(self, configuration): schemas = Registry.schemas for token, data in configuration.iteritems(): schema = schemas.get(token) if schema: data = schema.process(data, serialized=True) recursive_merge(self.configuration, {token: data}) else: recursive_merge(self.pending, {token: data})
def configure(self, configuration): if isinstance(configuration, basestring): configuration = Format.read(configuration, quiet=True) if not configuration: return includes = configuration.pop('include', None) recursive_merge(self.configuration, configuration) if includes: for pattern in includes: for include in sorted(glob(pattern)): self.configure(include) return self
def get_configuration(self, token): try: return self.configuration[token] except KeyError: pass self.guard.acquire() try: schemas = Registry.schemas for candidate in self.pending.keys(): schema = schemas.get(candidate) if schema: data = schema.process(self.pending.pop(candidate), serialized=True) recursive_merge(self.configuration, {candidate: data}) finally: self.guard.release() print self.configuration[token] return self.configuration[token]