|
1 | 1 | from .interface import Interface |
2 | 2 | from .utils import in_current_path |
3 | | -import os |
4 | 3 |
|
5 | 4 | 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__"): |
7 | 6 | location = location.__fspath__() |
8 | 7 | interface = Interface(shells=shells, all_shells=all_shells, home=home) |
9 | 8 | return interface.put(location, front=True, app_name=app_name, check=check) |
10 | 9 |
|
11 | 10 |
|
12 | 11 | 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__"): |
14 | 13 | location = location.__fspath__() |
15 | 14 | interface = Interface(shells=shells, all_shells=all_shells, home=home) |
16 | 15 | return interface.put(location, front=False, app_name=app_name, check=check) |
17 | 16 |
|
18 | 17 |
|
19 | 18 | 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__"): |
21 | 20 | location = location.__fspath__() |
22 | 21 | interface = Interface(shells=shells, all_shells=all_shells, home=home) |
23 | 22 | return interface.location_in_new_path(location, check=check) |
24 | 23 |
|
25 | 24 |
|
26 | 25 | def need_shell_restart(location, shells=None, all_shells=False, home=None): |
27 | | - if isinstance(location, os.PathLike): |
| 26 | + if hasattr(location, "__fspath__"): |
28 | 27 | location = location.__fspath__() |
29 | 28 | interface = Interface(shells=shells, all_shells=all_shells, home=home) |
30 | 29 | return not in_current_path(location) and interface.location_in_new_path(location) |
0 commit comments