mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
Merge pull request #506 from asergi/pathlib2
Switch from pathlib to pathlib2
This commit is contained in:
commit
a4b690369c
2
setup.py
2
setup.py
@ -29,7 +29,7 @@ elif (3, 0) < version < (3, 3):
|
|||||||
VERSION = '3.9'
|
VERSION = '3.9'
|
||||||
|
|
||||||
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
install_requires = ['psutil', 'colorama', 'six', 'decorator']
|
||||||
extras_require = {':python_version<"3.4"': ['pathlib'],
|
extras_require = {':python_version<"3.4"': ['pathlib2'],
|
||||||
":sys_platform=='win32'": ['win_unicode_console']}
|
":sys_platform=='win32'": ['win_unicode_console']}
|
||||||
|
|
||||||
setup(name='thefuck',
|
setup(name='thefuck',
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from pathlib import Path
|
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
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pathlib import Path
|
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 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
|
||||||
@ -11,7 +16,7 @@ class TestGetRules(object):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def glob(self, mocker):
|
def glob(self, mocker):
|
||||||
results = {}
|
results = {}
|
||||||
mocker.patch('pathlib.Path.glob',
|
mocker.patch(pathlib_name + '.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,7 +3,10 @@
|
|||||||
import os
|
import os
|
||||||
from subprocess import PIPE
|
from subprocess import PIPE
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
from pathlib import Path
|
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
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
from imp import load_source
|
from imp import load_source
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
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
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from pathlib import Path
|
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 . import logs
|
from . import logs
|
||||||
|
@ -10,7 +10,10 @@ 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 inspect import getargspec
|
from inspect import getargspec
|
||||||
from pathlib import Path
|
try:
|
||||||
|
from pathlib import Path
|
||||||
|
except ImportError:
|
||||||
|
from pathlib2 import Path
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
|
|
||||||
DEVNULL = open(os.devnull, 'w')
|
DEVNULL = open(os.devnull, 'w')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user