mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 12:58:33 +00:00
#N/A: Move imports from pathlib
/pathlib2
to utils
This commit is contained in:
parent
1f75fc1ea9
commit
176924c18d
@ -1,10 +1,7 @@
|
|||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
import pytest
|
import pytest
|
||||||
from thefuck import shells
|
from thefuck import shells
|
||||||
from thefuck import conf, const
|
from thefuck import conf, const
|
||||||
|
from thefuck.utils import Path
|
||||||
|
|
||||||
shells.shell = shells.Generic()
|
shells.shell = shells.Generic()
|
||||||
|
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
pathlib_name = 'pathlib'
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
pathlib_name = 'pathlib2'
|
|
||||||
from thefuck import corrector, const
|
from thefuck import corrector, const
|
||||||
|
from thefuck.utils import Path
|
||||||
from tests.utils import Rule, Command, CorrectedCommand
|
from tests.utils import Rule, Command, CorrectedCommand
|
||||||
from thefuck.corrector import get_corrected_commands, organize_commands
|
from thefuck.corrector import get_corrected_commands, organize_commands
|
||||||
|
|
||||||
@ -16,7 +11,7 @@ class TestGetRules(object):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def glob(self, mocker):
|
def glob(self, mocker):
|
||||||
results = {}
|
results = {}
|
||||||
mocker.patch(pathlib_name + '.Path.glob',
|
mocker.patch('thefuck.utils.Path.glob',
|
||||||
new_callable=lambda: lambda *_: results.pop('value', []))
|
new_callable=lambda: lambda *_: results.pop('value', []))
|
||||||
return lambda value: results.update({'value': value})
|
return lambda value: results.update({'value': value})
|
||||||
|
|
||||||
|
@ -3,14 +3,11 @@
|
|||||||
import os
|
import os
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
import pytest
|
import pytest
|
||||||
from tests.utils import CorrectedCommand, Rule, Command
|
from tests.utils import CorrectedCommand, Rule, Command
|
||||||
from thefuck import const
|
from thefuck import const
|
||||||
from thefuck.exceptions import EmptyCommand
|
from thefuck.exceptions import EmptyCommand
|
||||||
|
from thefuck.utils import Path
|
||||||
|
|
||||||
|
|
||||||
class TestCorrectedCommand(object):
|
class TestCorrectedCommand(object):
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
from imp import load_source
|
from imp import load_source
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
from six import text_type
|
from six import text_type
|
||||||
from . import const
|
from . import const
|
||||||
|
from .utils import Path
|
||||||
|
|
||||||
|
|
||||||
class Settings(dict):
|
class Settings(dict):
|
||||||
@ -43,14 +40,13 @@ class Settings(dict):
|
|||||||
|
|
||||||
def _get_user_dir_path(self):
|
def _get_user_dir_path(self):
|
||||||
# for backward compatibility, use `~/.thefuck` if it exists
|
# for backward compatibility, use `~/.thefuck` if it exists
|
||||||
legacy_user_dir = Path(os.path.expanduser('~/.thefuck'))
|
legacy_user_dir = Path('~/.thefuck').expanduser()
|
||||||
|
|
||||||
if legacy_user_dir.is_dir():
|
if legacy_user_dir.is_dir():
|
||||||
return legacy_user_dir
|
return legacy_user_dir
|
||||||
else:
|
else:
|
||||||
default_xdg_config_dir = os.path.expanduser("~/.config")
|
xdg_config_dir = os.getenv("XDG_CONFIG_HOME", "~/.config")
|
||||||
xdg_config_dir = os.getenv("XDG_CONFIG_HOME", default_xdg_config_dir)
|
return Path(xdg_config_dir).joinpath('thefuck')
|
||||||
return Path(os.path.join(xdg_config_dir, 'thefuck'))
|
|
||||||
|
|
||||||
def _setup_user_dir(self):
|
def _setup_user_dir(self):
|
||||||
"""Returns user config dir, create it when it doesn't exist."""
|
"""Returns user config dir, create it when it doesn't exist."""
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
from .conf import settings
|
from .conf import settings
|
||||||
from .types import Rule
|
from .types import Rule
|
||||||
|
from .utils import Path
|
||||||
from . import logs
|
from . import logs
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
try:
|
from thefuck.utils import for_app, replace_command, eager, memoize, Path
|
||||||
from pathlib import Path
|
|
||||||
except ImportError:
|
|
||||||
from pathlib2 import Path
|
|
||||||
|
|
||||||
from thefuck.utils import for_app, replace_command, eager, memoize
|
|
||||||
|
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
|
@ -4,16 +4,16 @@ import pkg_resources
|
|||||||
import re
|
import re
|
||||||
import shelve
|
import shelve
|
||||||
import six
|
import six
|
||||||
from .conf import settings
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from decorator import decorator
|
from decorator import decorator
|
||||||
from difflib import get_close_matches
|
from difflib import get_close_matches
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from warnings import warn
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from pathlib2 import Path
|
from pathlib2 import Path
|
||||||
from warnings import warn
|
|
||||||
|
|
||||||
DEVNULL = open(os.devnull, 'w')
|
DEVNULL = open(os.devnull, 'w')
|
||||||
|
|
||||||
@ -81,6 +81,8 @@ def default_settings(params):
|
|||||||
print(settings.apt)
|
print(settings.apt)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from .conf import settings
|
||||||
|
|
||||||
def _default_settings(fn, command):
|
def _default_settings(fn, command):
|
||||||
for k, w in params.items():
|
for k, w in params.items():
|
||||||
settings.setdefault(k, w)
|
settings.setdefault(k, w)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user