Ejemplo n.º 1
0
    def get_target_dict(self, name, version=None, **kwargs):
        """Step through the various levels of dependencies to get the
        full dictionary for a target.

        target: version -> ... -> target: default -> default: type
        """
        n, v = item_version(name)
        if version is not None and v is not None:
            msg = "Version specified twice: %s, %s" % (name, version)
            raise ValueError(msg)

        if v is not None:
            version = v
        if version is None:
            version = 'default'
        name = n

        # Start with the target:version requested
        ret = self.library[name][version]

        # Walk down the chain until we either return None or the
        # 'default' version
        ret['version'] = version
        while (version is not None) and (version != 'default'):
            version = ret.get('base', 'default')
            ret = merge_dict(self.library[name][version], ret)
        kwargs['name'] = name
        # And finally, overwrite with kwargs
        update_dict(ret, kwargs)
        return ret
Ejemplo n.º 2
0
    def get_target_dict(self, name, version=None, **kwargs):
        """ Step through the various levels of dependencies to get the
        full dictionary for a target.

        target: version -> ... -> target: default -> default: type
        """
        n, v = item_version(name)
        if version is not None and v is not None:
            msg = "Version specified twice: %s, %s" % (name, version)
            raise ValueError(msg)

        if v is not None:
            version = v
        if version is None:
            version = "default"
        name = n

        # Start with the target:version requested
        ret = self.library[name][version]

        # Walk down the chain until we either return None or the
        # 'default' version
        while (version is not None) and (version != "default"):
            version = ret.get("base", "default")
            ret = merge_dict(self.library[name][version], ret)
        ret["version"] = version
        kwargs["name"] = name
        # And finally, overwrite with kwargs
        update_dict(ret, kwargs)
        return ret
Ejemplo n.º 3
0
 def load_library(cls, paths):
     library = dict()
     for path in paths:
         # Should use logging
         print("Using %s for %s"%(path,cls.__name__))
         subdirs = [path] + os.walk(path).next()[1]
         for subdir in subdirs:
             infiles = glob.glob(join(path,subdir)+'/*.yaml')
             for f in infiles:
                 d = yaml_load(f)
                 update_dict(library,d)
     return library