#441: Remove shells methods wrappers

This commit is contained in:
nvbn
2016-01-29 13:09:40 +03:00
parent b5dc7aab6d
commit fe07fcaa62
34 changed files with 86 additions and 119 deletions
+4 -46
View File
@@ -3,10 +3,7 @@ implement `from_shell`, `to_shell`, `app_alias`, `put_to_history` and
`get_aliases` methods.
"""
import os
import sys
from psutil import Process
from ..utils import memoize
from .. import logs
from .bash import Bash
from .fish import Fish
from .generic import Generic
@@ -20,51 +17,12 @@ shells = {'bash': Bash,
'tcsh': Tcsh}
@memoize
def _get_shell():
try:
shell = Process(os.getpid()).parent().name()
shell_name = Process(os.getpid()).parent().name()
except TypeError:
shell = Process(os.getpid()).parent.name
return shells.get(shell, Generic)()
shell_name = Process(os.getpid()).parent.name
return shells.get(shell_name, Generic)()
# Public interface of current shell:
def from_shell(command):
return _get_shell().from_shell(command)
def to_shell(command):
return _get_shell().to_shell(command)
def app_alias(alias):
return _get_shell().app_alias(alias)
def put_to_history(command):
return _get_shell().put_to_history(command)
def and_(*commands):
return _get_shell().and_(*commands)
def get_aliases():
return _get_shell().get_aliases()
def split_command(command):
return _get_shell().split_command(command)
def quote(s):
return _get_shell().quote(s)
def get_history():
return _get_shell().get_history()
def how_to_configure():
return _get_shell().how_to_configure()
shell = _get_shell()