예제 #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
파일: runtime.py 프로젝트: siq-legacy/spire
    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
파일: runtime.py 프로젝트: omersaeed/spire
    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]