From 20be070c7a58ba9fea384ebb7966a31737ea481d Mon Sep 17 00:00:00 2001 From: Bryan Hu Date: Fri, 22 Jan 2021 18:33:00 -0800 Subject: [PATCH] Patched for python2 support --- userpath/core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/userpath/core.py b/userpath/core.py index e5b0587..b647676 100644 --- a/userpath/core.py +++ b/userpath/core.py @@ -1,30 +1,29 @@ from .interface import Interface from .utils import in_current_path -import os def prepend(location, app_name=None, shells=None, all_shells=False, home=None, check=False): - if isinstance(location, os.PathLike): + if hasattr(location, "__fspath__"): location = location.__fspath__() interface = Interface(shells=shells, all_shells=all_shells, home=home) return interface.put(location, front=True, app_name=app_name, check=check) def append(location, app_name=None, shells=None, all_shells=False, home=None, check=False): - if isinstance(location, os.PathLike): + if hasattr(location, "__fspath__"): location = location.__fspath__() interface = Interface(shells=shells, all_shells=all_shells, home=home) return interface.put(location, front=False, app_name=app_name, check=check) def in_new_path(location, shells=None, all_shells=False, home=None, check=False): - if isinstance(location, os.PathLike): + if hasattr(location, "__fspath__"): location = location.__fspath__() interface = Interface(shells=shells, all_shells=all_shells, home=home) return interface.location_in_new_path(location, check=check) def need_shell_restart(location, shells=None, all_shells=False, home=None): - if isinstance(location, os.PathLike): + if hasattr(location, "__fspath__"): location = location.__fspath__() interface = Interface(shells=shells, all_shells=all_shells, home=home) return not in_current_path(location) and interface.location_in_new_path(location)