Exemple #1
0
    def _create_parser(cls, seed_values=None):
        """Creates a config parser that supports %([key-name])s value substitution.

    A handful of seed values will be set to act as if specified in the loaded config file's DEFAULT
    section, and be available for use in substitutions.  The caller may override some of these
    seed values.

    :param seed_values: A dict with optional override seed values for buildroot, pants_workdir,
                        pants_supportdir and pants_distdir.
    """
        seed_values = seed_values or {}
        buildroot = seed_values.get('buildroot', get_buildroot())

        all_seed_values = {
            'buildroot': buildroot,
            'homedir': os.path.expanduser('~'),
            'user': getpass.getuser(),
            'pants_bootstrapdir': get_pants_cachedir(),
            'pants_configdir': get_pants_configdir(),
        }

        def update_dir_from_seed_values(key, default):
            all_seed_values[key] = seed_values.get(
                key, os.path.join(buildroot, default))

        update_dir_from_seed_values('pants_workdir', '.pants.d')
        update_dir_from_seed_values('pants_supportdir', 'build-support')
        update_dir_from_seed_values('pants_distdir', 'dist')

        return configparser.ConfigParser(all_seed_values)
Exemple #2
0
    def _generate_coverage_config(self, src_to_target_base):
        cp = configparser.ConfigParser()
        cp.read_file(StringIO(self.DEFAULT_COVERAGE_CONFIG))

        self._add_plugin_config(cp, self._source_chroot_path,
                                src_to_target_base)

        # See the debug options here: http://nedbatchelder.com/code/coverage/cmd.html#cmd-run-debug
        if self._debug:
            debug_options = self._format_string_list([
                # Dumps the coverage config realized values.
                'config',
                # Logs which files are skipped or traced and why.
                'trace'
            ])
            self._ensure_section(cp, 'run')
            cp.set('run', 'debug', debug_options)

        return cp