How to use the thefuck.utils.memoize function in thefuck

To help you get started, we’ve selected a few thefuck examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nvbn / thefuck / tests / test_utils.py View on Github external
def test_no_memoize():
    fn = Mock(__name__='fn')
    memoized = memoize(fn)
    memoized()
    memoized()
    assert fn.call_count == 2
github nvbn / thefuck / tests / test_utils.py View on Github external
def test_memoize():
    fn = Mock(__name__='fn')
    memoized = memoize(fn)
    memoized()
    memoized()
    fn.assert_called_once_with()
github nvbn / thefuck / thefuck / shells.py View on Github external
    @memoize
    @cache('.bashrc', '.bash_profile')
    def get_aliases(self):
        proc = Popen(['bash', '-ic', 'alias'], stdout=PIPE, stderr=DEVNULL)
        return dict(
                self._parse_alias(alias)
                for alias in proc.stdout.read().decode('utf-8').split('\n')
                if alias and '=' in alias)
github nvbn / thefuck / thefuck / rules / missing_space_before_subcommand.py View on Github external
@memoize
def _get_executable(script_part):
    for executable in get_all_executables():
        if script_part.startswith(executable):
            return executable
github nvbn / thefuck / thefuck / shells.py View on Github external
@memoize
def get_history():
    return list(_get_shell().get_history())
github nvbn / thefuck / thefuck / rules / path_from_history.py View on Github external
@memoize
def _get_destination(command):
    for pattern in patterns:
        found = re.findall(pattern, command.output)
        if found:
            if found[0] in command.script_parts:
                return found[0]
github nvbn / thefuck / thefuck / rules / fix_file.py View on Github external
@memoize
def _search(output):
    for pattern in patterns:
        m = pattern(output)
        if m and os.path.isfile(m.group('file')):
            return m
github nvbn / thefuck / thefuck / specific / brew.py View on Github external
@memoize
def get_brew_path_prefix():
    """To get brew path"""
    try:
        return subprocess.check_output(['brew', '--prefix'],
                                       universal_newlines=True).strip()
    except Exception:
        return None
github nvbn / thefuck / thefuck / shells / generic.py View on Github external
    @memoize
    def get_history(self):
        return list(self._get_history_lines())
github nvbn / thefuck / thefuck / rules / port_already_in_use.py View on Github external
@memoize
def _get_used_port(command):
    for pattern in patterns:
        matched = re.search(pattern, command.output)
        if matched:
            return matched.group('port')