mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 22:54:14 +00:00 
			
		
		
		
	#N/A: Move imports from pathlib/pathlib2 to utils
				
					
				
			This commit is contained in:
		| @@ -1,10 +1,7 @@ | ||||
| try: | ||||
|     from pathlib import Path | ||||
| except ImportError: | ||||
|     from pathlib2 import Path | ||||
| import pytest | ||||
| from thefuck import shells | ||||
| from thefuck import conf, const | ||||
| from thefuck.utils import Path | ||||
|  | ||||
| shells.shell = shells.Generic() | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,8 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
|  | ||||
| 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.utils import Path | ||||
| from tests.utils import Rule, Command, CorrectedCommand | ||||
| from thefuck.corrector import get_corrected_commands, organize_commands | ||||
|  | ||||
| @@ -16,7 +11,7 @@ class TestGetRules(object): | ||||
|     @pytest.fixture | ||||
|     def glob(self, mocker): | ||||
|         results = {} | ||||
|         mocker.patch(pathlib_name + '.Path.glob', | ||||
|         mocker.patch('thefuck.utils.Path.glob', | ||||
|                      new_callable=lambda: lambda *_: results.pop('value', [])) | ||||
|         return lambda value: results.update({'value': value}) | ||||
|  | ||||
|   | ||||
| @@ -3,14 +3,11 @@ | ||||
| import os | ||||
| from subprocess import PIPE | ||||
| from mock import Mock | ||||
| try: | ||||
|     from pathlib import Path | ||||
| except ImportError: | ||||
|     from pathlib2 import Path | ||||
| import pytest | ||||
| from tests.utils import CorrectedCommand, Rule, Command | ||||
| from thefuck import const | ||||
| from thefuck.exceptions import EmptyCommand | ||||
| from thefuck.utils import Path | ||||
|  | ||||
|  | ||||
| class TestCorrectedCommand(object): | ||||
|   | ||||
| @@ -1,12 +1,9 @@ | ||||
| from imp import load_source | ||||
| import os | ||||
| import sys | ||||
| try: | ||||
|     from pathlib import Path | ||||
| except ImportError: | ||||
|     from pathlib2 import Path | ||||
| from six import text_type | ||||
| from . import const | ||||
| from .utils import Path | ||||
|  | ||||
|  | ||||
| class Settings(dict): | ||||
| @@ -43,14 +40,13 @@ class Settings(dict): | ||||
|  | ||||
|     def _get_user_dir_path(self): | ||||
|         # 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(): | ||||
|             return legacy_user_dir | ||||
|         else: | ||||
|             default_xdg_config_dir = os.path.expanduser("~/.config") | ||||
|             xdg_config_dir = os.getenv("XDG_CONFIG_HOME", default_xdg_config_dir) | ||||
|             return Path(os.path.join(xdg_config_dir, 'thefuck')) | ||||
|             xdg_config_dir = os.getenv("XDG_CONFIG_HOME", "~/.config") | ||||
|             return Path(xdg_config_dir).joinpath('thefuck') | ||||
|  | ||||
|     def _setup_user_dir(self): | ||||
|         """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 .types import Rule | ||||
| from .utils import Path | ||||
| from . import logs | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,4 @@ | ||||
| try: | ||||
|     from pathlib import Path | ||||
| except ImportError: | ||||
|     from pathlib2 import Path | ||||
|  | ||||
| from thefuck.utils import for_app, replace_command, eager, memoize | ||||
| from thefuck.utils import for_app, replace_command, eager, memoize, Path | ||||
|  | ||||
|  | ||||
| @memoize | ||||
|   | ||||
| @@ -4,16 +4,16 @@ import pkg_resources | ||||
| import re | ||||
| import shelve | ||||
| import six | ||||
| from .conf import settings | ||||
| from contextlib import closing | ||||
| 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 warnings import warn | ||||
|  | ||||
| DEVNULL = open(os.devnull, 'w') | ||||
|  | ||||
| @@ -81,6 +81,8 @@ 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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user