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

#N/A: Monkeypatch pathlib on windows

This commit is contained in:
Vladimir Iakovlev 2016-08-14 15:15:03 +03:00
parent 176924c18d
commit 621b455334
9 changed files with 27 additions and 14 deletions

View File

@ -1,7 +1,7 @@
import pytest
from thefuck import shells
from thefuck import conf, const
from thefuck.utils import Path
from thefuck.system import Path
shells.shell = shells.Generic()

View File

@ -2,7 +2,7 @@
import pytest
from thefuck import corrector, const
from thefuck.utils import Path
from thefuck.system import Path
from tests.utils import Rule, Command, CorrectedCommand
from thefuck.corrector import get_corrected_commands, organize_commands
@ -11,7 +11,7 @@ class TestGetRules(object):
@pytest.fixture
def glob(self, mocker):
results = {}
mocker.patch('thefuck.utils.Path.glob',
mocker.patch('thefuck.system.Path.glob',
new_callable=lambda: lambda *_: results.pop('value', []))
return lambda value: results.update({'value': value})

View File

@ -7,7 +7,7 @@ import pytest
from tests.utils import CorrectedCommand, Rule, Command
from thefuck import const
from thefuck.exceptions import EmptyCommand
from thefuck.utils import Path
from thefuck.system import Path
class TestCorrectedCommand(object):

View File

@ -3,7 +3,7 @@ import os
import sys
from six import text_type
from . import const
from .utils import Path
from .system import Path
class Settings(dict):

View File

@ -1,6 +1,6 @@
from .conf import settings
from .types import Rule
from .utils import Path
from .system import Path
from . import logs

View File

@ -1,4 +1,5 @@
from thefuck.utils import for_app, replace_command, eager, memoize, Path
from thefuck.utils import for_app, replace_command, eager, memoize
from thefuck.system import Path
@memoize

View File

@ -33,3 +33,8 @@ def get_key():
return const.KEY_DOWN
return ch
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path

View File

@ -25,3 +25,15 @@ def get_key():
encoding = sys.stdout.encoding or os.environ.get('PYTHONIOENCODING', 'utf-8')
return ch.decode(encoding)
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path
def _expanduser(self):
return self.__class__(os.path.expanduser(str(self)))
# pathlib's expanduser fails on windows, see http://bugs.python.org/issue19776
Path.expanduser = _expanduser

View File

@ -9,11 +9,8 @@ from decorator import decorator
from difflib import get_close_matches
from functools import wraps
from warnings import warn
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path
from .conf import settings
from .system import Path
DEVNULL = open(os.devnull, 'w')
@ -81,8 +78,6 @@ def default_settings(params):
print(settings.apt)
"""
from .conf import settings
def _default_settings(fn, command):
for k, w in params.items():
settings.setdefault(k, w)