Example #1
0
    def __init__(self, cwd=None, config=None, options=None):
        if cwd is None:
            cwd = os.getcwd() if config is None else os.path.dirname(config)
        self.cwd = cwd

        config = ConfigNode.from_file(config, fail_silent=True)
        file_config = ConfigNode.from_filesystem(cwd)
        if config:
            config.extend_last(file_config)
        else:
            config = file_config if file_config else ConfigNode()

        self.config = config
        self.config.add_commandline_options(listify(options))
        self.parser = Parser(self.config)
Example #2
0
    def __init__(self, cwd=None, config=None, options=None):
        """
        Build instance to invoke lbuild methods.

        Args:
            cwd -- Current working directly. If specified lbuild will
                search for a configuration file in this folder.
            config -- Path to a configuration file. If specified options,
                repositories etc. will be loaded from there.
            options -- List of options. Must be list of strings in a
                "key=value" format.
        """
        if cwd is None:
            if config is None:
                cwd = os.getcwd()
            else:
                cwd = os.path.abspath(os.path.dirname(config))
        self.cwd = cwd

        file_config = None
        filesystem_config = ConfigNode.from_path(self.cwd)

        # 0. config is default, but file doesn't exist, config = None
        if config == "project.xml":
            config = os.path.join(self.cwd, config)
            if not os.path.exists(config):
                config = None

        # 1. config is None: use filesystem config
        if config is None:
            if filesystem_config is None:
                file_config = ConfigNode()
            else:
                file_config = filesystem_config

        # 2. config is alias: create virtual config and extend it with alias
        elif ":" in config:
            file_config = ConfigNode()
            file_config.filename = "command-line"
            file_config._extends["command-line"].append(config)

        # 3. config is file: create file config and extend if with filesystem config
        else:
            file_config = ConfigNode.from_file(config)
            if file_config is not None:
                file_config.extend_last(filesystem_config)

        self.config = file_config
        self.config.add_commandline_options(listify(options))
        self.parser = Parser(self.config)
Example #3
0
 def _parse_config(self, filename):
     return ConfigNode.from_file(self._get_path(filename)).flatten()
Example #4
0
 def _find_config(self, startpath=None, **kw):
     if startpath: startpath = self._get_path(startpath)
     config = ConfigNode.from_filesystem(startpath, **kw)
     return config.flatten() if config else config