示例#1
0
    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
示例#2
0
文件: runtime.py 项目: esho/spire
    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
示例#3
0
文件: assembly.py 项目: esho/spire
 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})
示例#4
0
 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})
示例#5
0
    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
示例#6
0
    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
示例#7
0
文件: assembly.py 项目: esho/spire
    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]
示例#8
0
    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]