コード例 #1
0
def _get_all_environments():
    root = Path('~/.virtualenvs').expanduser()
    if not root.is_dir():
        return

    for child in root.iterdir():
        if child.is_dir():
            yield child.name
コード例 #2
0
def settings(request):
    def _reset_settings():
        conf.settings.clear()
        conf.settings.update(const.DEFAULT_SETTINGS)

    request.addfinalizer(_reset_settings)
    conf.settings.user_dir = Path('~/.thedick')
    return conf.settings
コード例 #3
0
ファイル: test_corrector.py プロジェクト: joujou333/thefuck
 def test_get_rules(self, glob, settings, paths, conf_rules, exclude_rules,
                    loaded_rules):
     glob([Path(path) for path in paths])
     settings.update(rules=conf_rules,
                     priority={},
                     exclude_rules=exclude_rules)
     rules = corrector.get_rules()
     self._compare_names(rules, loaded_rules)
コード例 #4
0
def get_new_command(command):
    destination = _get_destination(command)
    paths = _get_all_absolute_paths_from_history(command)

    return [
        replace_argument(command.script, destination, path) for path in paths
        if path.endswith(destination) and Path(path).expanduser().exists()
    ]
コード例 #5
0
 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch(
         'thedick.types.load_source',
         return_value=Mock(match=match,
                           get_new_command=get_new_command,
                           enabled_by_default=True,
                           priority=900,
                           requires_output=True))
     rule_path = os.path.join(os.sep, 'rules', 'bash.py')
     assert (Rule.from_path(Path(rule_path))
             == Rule('bash', match, get_new_command, priority=900))
     load_source.assert_called_once_with('bash', rule_path)
コード例 #6
0
ファイル: scm_correction.py プロジェクト: joujou333/thefuck
def _get_actual_scm():
    for path, scm in path_to_scm.items():
        if Path(path).is_dir():
            return scm
コード例 #7
0
def source_root():
    return Path(__file__).parent.parent.resolve()
コード例 #8
0
def _get_missing_file(command):
    pathspec = re.findall(
        r"error: pathspec '([^']*)' "
        r'did not match any file\(s\) known to git.', command.output)[0]
    if Path(pathspec).exists():
        return pathspec