Esempio n. 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
Esempio n. 2
0
def source_root():
    return Path(__file__).parent.parent.resolve()
Esempio n. 3
0
def _get_actual_scm():
    for path, scm in path_to_scm.items():
        if Path(path).is_dir():
            return scm
Esempio n. 4
0
 def test_from_path_excluded_rule(self, mocker, settings):
     load_source = mocker.patch('thefuck.types.load_source')
     settings.update(exclude_rules=['git'])
     rule_path = os.path.join(os.sep, 'rules', 'git.py')
     assert Rule.from_path(Path(rule_path)) is None
     assert not load_source.called
Esempio n. 5
0
 def test_from_path_rule_exception(self, mocker):
     load_source = mocker.patch('thefuck.types.load_source',
                                side_effect=ImportError("No module named foo..."))
     assert Rule.from_path(Path('git.py')) is None
     load_source.assert_called_once_with('git', 'git.py')
Esempio n. 6
0
def test_get_rules_rule_exception(mocker, glob):
    load_source = mocker.patch('thefuck.types.load_source',
                               side_effect=ImportError("No module named foo..."))
    glob([Path('git.py')])
    assert not corrector.get_rules()
    load_source.assert_called_once_with('git', 'git.py')
Esempio n. 7
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