1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 18:21:10 +00:00

#441: Remove all logic from shells methods wrappers

This commit is contained in:
nvbn 2016-01-29 12:30:31 +03:00
parent a2ec5aa3ff
commit b5dc7aab6d
2 changed files with 18 additions and 8 deletions

View File

@ -43,10 +43,7 @@ def app_alias(alias):
def put_to_history(command): def put_to_history(command):
try:
return _get_shell().put_to_history(command) return _get_shell().put_to_history(command)
except IOError:
logs.exception("Can't update history", sys.exc_info())
def and_(*commands): def and_(*commands):
@ -54,7 +51,7 @@ def and_(*commands):
def get_aliases(): def get_aliases():
return list(_get_shell().get_aliases().keys()) return _get_shell().get_aliases()
def split_command(command): def split_command(command):
@ -65,9 +62,8 @@ def quote(s):
return _get_shell().quote(s) return _get_shell().quote(s)
@memoize
def get_history(): def get_history():
return list(_get_shell().get_history()) return _get_shell().get_history()
def how_to_configure(): def how_to_configure():

View File

@ -2,7 +2,11 @@ import io
import os import os
import shlex import shlex
import six import six
import sys
from ..utils import memoize
from ..conf import settings from ..conf import settings
from .. import logs
class Generic(object): class Generic(object):
@ -35,7 +39,13 @@ class Generic(object):
def _get_history_line(self, command_script): def _get_history_line(self, command_script):
return '' return ''
def put_to_history(self, command_script): def put_to_history(self, command):
try:
return self._put_to_history(command)
except IOError:
logs.exception("Can't update history", sys.exc_info())
def _put_to_history(self, command_script):
"""Puts command script to shell history.""" """Puts command script to shell history."""
history_file_name = self._get_history_file_name() history_file_name = self._get_history_file_name()
if os.path.isfile(history_file_name): if os.path.isfile(history_file_name):
@ -46,7 +56,11 @@ class Generic(object):
else: else:
history.write(entry) history.write(entry)
@memoize
def get_history(self): def get_history(self):
return list(self._get_history_lines())
def _get_history_lines(self):
"""Returns list of history entries.""" """Returns list of history entries."""
history_file_name = self._get_history_file_name() history_file_name = self._get_history_file_name()
if os.path.isfile(history_file_name): if os.path.isfile(history_file_name):