コード例 #1
0
    def get_file_path(self, env):
        cwd = Path(env['cwd'])
        path_list_to_search = [cwd] + list(cwd.parents)

        for project_path in path_list_to_search:
            for basename in PROJECT_CONFIG_FILENAMES:
                proj_conf_path_tmp = project_path / basename

                if proj_conf_path_tmp.is_file():
                    return proj_conf_path_tmp

        return get_asset_path('void_config.yaml')
コード例 #2
0
from typing import Dict  # noqa: F401
from pathlib import Path
from vint.utils.array import flat_map
from vint.asset import get_asset_path
from vint.linting.config.config_filenames import CONFIG_FILENAMES
from vint.linting.config.config_file_source import ConfigFileSource

VOID_CONFIG_PATH = get_asset_path('void_config.yaml')


class ConfigGlobalSource(ConfigFileSource):
    def get_file_path(self, env):
        global_config_paths = ConfigGlobalSource._get_filenames_candidates(env)

        for global_config_path in global_config_paths:
            if global_config_path.is_file():
                return global_config_path

        return VOID_CONFIG_PATH

    @classmethod
    def _get_filenames_candidates(cls, env):
        # type: (Dict[str, str]) -> [Path]
        global_config_dir_candidates = [
            env['xdg_config_home'],
            env['home_path'],
        ]

        return flat_map(
            lambda directory: ConfigGlobalSource.
            _get_filenames_candidates_from_dir(directory),
コード例 #3
0
from pathlib import Path
from vint.asset import get_asset_path
from vint.linting.config.config_file_source import ConfigFileSource

PROJECT_CONFIG_FILENAMES = [
    '.vintrc.yaml',
    '.vintrc.yml',
    '.vintrc',
]
VOID_CONFIG_PATH = get_asset_path('void_config.yaml')


class ConfigProjectSource(ConfigFileSource):
    def get_file_path(self, env):
        proj_conf_path = VOID_CONFIG_PATH

        path_list_to_search = [Path(env['cwd'])] + list(Path(env['cwd']).parents)

        for project_path in path_list_to_search:
            for basename in PROJECT_CONFIG_FILENAMES:
                proj_conf_path_tmp = project_path / basename

                if proj_conf_path_tmp.is_file():
                    return proj_conf_path_tmp

        return proj_conf_path
コード例 #4
0
from vint.asset import get_asset_path
from vint.linting.config.config_file_source import ConfigFileSource


DEFAULT_CONFIG_PATH = get_asset_path('default_config.yaml')


class ConfigDefaultSource(ConfigFileSource):
    def get_file_path(self, env):
        return DEFAULT_CONFIG_PATH