1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-13 22:28:33 +00:00

#611: Fix python 2 support

This commit is contained in:
Vladimir Iakovlev 2017-03-13 23:26:57 +01:00
parent 2315929875
commit 408cb5fa09
6 changed files with 10 additions and 9 deletions

View File

@ -5,6 +5,7 @@ init_output()
import os # noqa: E402
from psutil import Process # noqa: E402
import six # noqa: E402
from . import logs # noqa: E402
from .shells import shell # noqa: E402
from .conf import settings # noqa: E402
@ -30,7 +31,7 @@ def _get_not_configured_usage_tracker_path():
def _record_first_run():
"""Records shell pid to tracker file."""
with _get_not_configured_usage_tracker_path().open('w') as tracker:
tracker.write(str(_get_shell_pid()))
tracker.write(six.text_type(_get_shell_pid()))
def _is_second_run():
@ -41,7 +42,7 @@ def _is_second_run():
current_pid = _get_shell_pid()
with tracker_path.open('r') as tracker:
return tracker.read() == str(current_pid)
return tracker.read() == six.text_type(current_pid)
def _is_already_configured(configuration_details):
@ -55,9 +56,9 @@ def _configure(configuration_details):
"""Adds alias to shell config."""
path = Path(configuration_details.path).expanduser()
with path.open('a') as shell_config:
shell_config.write('\n')
shell_config.write(u'\n')
shell_config.write(configuration_details.content)
shell_config.write('\n')
shell_config.write(u'\n')
def main():

View File

@ -46,6 +46,6 @@ class Bash(Generic):
config = 'bash config'
return self._create_shell_configuration(
content='eval $(thefuck --alias)',
content=u'eval $(thefuck --alias)',
path=config,
reload=u'source {}'.format(config))

View File

@ -68,7 +68,7 @@ class Fish(Generic):
def how_to_configure(self):
return self._create_shell_configuration(
content=r"eval (thefuck --alias | tr '\n' ';')",
content=u"eval (thefuck --alias | tr '\n' ';')",
path='~/.config/fish/config.fish',
reload='fish')

View File

@ -19,7 +19,7 @@ class Powershell(Generic):
def how_to_configure(self):
return ShellConfiguration(
content='iex "thefuck --alias"',
content=u'iex "thefuck --alias"',
path='$profile',
reload='& $profile',
can_configure_automatically=False)

View File

@ -32,6 +32,6 @@ class Tcsh(Generic):
def how_to_configure(self):
return self._create_shell_configuration(
content='eval `thefuck --alias`',
content=u'eval `thefuck --alias`',
path='~/.tcshrc',
reload='tcsh')

View File

@ -46,6 +46,6 @@ class Zsh(Generic):
def how_to_configure(self):
return self._create_shell_configuration(
content='eval $(thefuck --alias)',
content=u'eval $(thefuck --alias)',
path='~/.zshrc',
reload='source ~/.zshrc')