Skip to content

Commit 90d04d3

Browse files
authored
Patched for python2 support
1 parent 3ffb82d commit 90d04d3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

userpath/core.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
from .interface import Interface
22
from .utils import in_current_path
3-
import os
3+
try:
4+
from os import PathLike
5+
except ImportError:
6+
PathLike = None
47

58
def prepend(location, app_name=None, shells=None, all_shells=False, home=None, check=False):
6-
if isinstance(location, os.PathLike):
9+
if isinstance(location, PathLike) and PathLike is not None:
710
location = location.__fspath__()
811
interface = Interface(shells=shells, all_shells=all_shells, home=home)
912
return interface.put(location, front=True, app_name=app_name, check=check)
1013

1114

1215
def append(location, app_name=None, shells=None, all_shells=False, home=None, check=False):
13-
if isinstance(location, os.PathLike):
16+
if isinstance(location, PathLike):
1417
location = location.__fspath__()
1518
interface = Interface(shells=shells, all_shells=all_shells, home=home)
1619
return interface.put(location, front=False, app_name=app_name, check=check)
1720

1821

1922
def in_new_path(location, shells=None, all_shells=False, home=None, check=False):
20-
if isinstance(location, os.PathLike):
23+
if isinstance(location, PathLike) and PathLike is not None:
2124
location = location.__fspath__()
2225
interface = Interface(shells=shells, all_shells=all_shells, home=home)
2326
return interface.location_in_new_path(location, check=check)
2427

2528

2629
def need_shell_restart(location, shells=None, all_shells=False, home=None):
27-
if isinstance(location, os.PathLike):
30+
if isinstance(location, PathLike) and PathLike is not None:
2831
location = location.__fspath__()
2932
interface = Interface(shells=shells, all_shells=all_shells, home=home)
3033
return not in_current_path(location) and interface.location_in_new_path(location)

0 commit comments

Comments
 (0)