Skip to content

Commit

Permalink
Patched for python2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatXliner committed Jan 23, 2021
1 parent 3ffb82d commit 20be070
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions userpath/core.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 20be070

Please sign in to comment.