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