Skip to content

Commit 20be070

Browse files
committed
Patched for python2 support
1 parent 3ffb82d commit 20be070

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

userpath/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
from .interface import Interface
22
from .utils import in_current_path
3-
import os
43

54
def prepend(location, app_name=None, shells=None, all_shells=False, home=None, check=False):
6-
if isinstance(location, os.PathLike):
5+
if hasattr(location, "__fspath__"):
76
location = location.__fspath__()
87
interface = Interface(shells=shells, all_shells=all_shells, home=home)
98
return interface.put(location, front=True, app_name=app_name, check=check)
109

1110

1211
def append(location, app_name=None, shells=None, all_shells=False, home=None, check=False):
13-
if isinstance(location, os.PathLike):
12+
if hasattr(location, "__fspath__"):
1413
location = location.__fspath__()
1514
interface = Interface(shells=shells, all_shells=all_shells, home=home)
1615
return interface.put(location, front=False, app_name=app_name, check=check)
1716

1817

1918
def in_new_path(location, shells=None, all_shells=False, home=None, check=False):
20-
if isinstance(location, os.PathLike):
19+
if hasattr(location, "__fspath__"):
2120
location = location.__fspath__()
2221
interface = Interface(shells=shells, all_shells=all_shells, home=home)
2322
return interface.location_in_new_path(location, check=check)
2423

2524

2625
def need_shell_restart(location, shells=None, all_shells=False, home=None):
27-
if isinstance(location, os.PathLike):
26+
if hasattr(location, "__fspath__"):
2827
location = location.__fspath__()
2928
interface = Interface(shells=shells, all_shells=all_shells, home=home)
3029
return not in_current_path(location) and interface.location_in_new_path(location)

0 commit comments

Comments
 (0)