Ejemplo n.º 1
0
def _get_all_absolute_paths_from_history(command):
    counter = Counter()

    for line in get_valid_history_without_current(command):
        splitted = shell.split_command(line)

        for param in splitted[1:]:
            if param.startswith("/") or param.startswith("~"):
                if param.endswith("/"):
                    param = param[:-1]

                counter[param] += 1

    return (path for path, _ in counter.most_common(None))
Ejemplo n.º 2
0
def _get_all_absolute_paths_from_history(command):
    counter = Counter()

    for line in get_valid_history_without_current(command):
        splitted = shell.split_command(line)

        for param in splitted[1:]:
            if param.startswith('/') or param.startswith('~'):
                if param.endswith('/'):
                    param = param[:-1]

                counter[param] += 1

    return (path for path, _ in counter.most_common(None))
Ejemplo n.º 3
0
 def test_get_valid_history_without_current(self, script, result):
     command = Command(script=script)
     assert get_valid_history_without_current(command) == result
Ejemplo n.º 4
0
 def test_get_valid_history_without_current(self, script, result):
     command = Command(script, "")
     assert get_valid_history_without_current(command) == result
Ejemplo n.º 5
0
def _get_used_executables(command):
    for script in get_valid_history_without_current(command):
        yield script.split(' ')[0]
Ejemplo n.º 6
0
def _get_used_executables(command):
    for script in get_valid_history_without_current(command):
        yield script.split(' ')[0]
Ejemplo n.º 7
0
 def test_get_valid_history_without_current(self, script):
     command = Command(script, '')
     assert script not in get_valid_history_without_current(command)
Ejemplo n.º 8
0
def match(command):
    return len(
        get_close_matches(command.script,
                          get_valid_history_without_current(command)))
Ejemplo n.º 9
0
def get_new_command(command):
    return get_closest(command.script,
                       get_valid_history_without_current(command))
Ejemplo n.º 10
0
def get_new_command(command):
    return get_closest(command.script,
                       get_valid_history_without_current(command))
Ejemplo n.º 11
0
def match(command):
    return len(get_close_matches(command.script,
                                 get_valid_history_without_current(command)))