summaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/utils/path.py
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
committerrobot-contrib <[email protected]>2022-05-18 00:43:36 +0300
commit9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch)
tree78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/utils/path.py
parent8113a823ffca6451bb5ff8f0334560885a939a24 (diff)
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/utils/path.py')
-rw-r--r--contrib/python/ipython/py3/IPython/utils/path.py72
1 files changed, 14 insertions, 58 deletions
diff --git a/contrib/python/ipython/py3/IPython/utils/path.py b/contrib/python/ipython/py3/IPython/utils/path.py
index 0fb6144e19f..3db33e4c43e 100644
--- a/contrib/python/ipython/py3/IPython/utils/path.py
+++ b/contrib/python/ipython/py3/IPython/utils/path.py
@@ -33,14 +33,14 @@ if sys.platform == 'win32':
Examples
--------
- >>> get_long_path_name('c:\\docume~1')
+ >>> get_long_path_name('c:\\\\docume~1')
'c:\\\\Documents and Settings'
"""
try:
import ctypes
- except ImportError:
- raise ImportError('you need to have ctypes installed for this to work')
+ except ImportError as e:
+ raise ImportError('you need to have ctypes installed for this to work') from e
_GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
_GetLongPathName.argtypes = [ctypes.c_wchar_p, ctypes.c_wchar_p,
ctypes.c_uint ]
@@ -67,20 +67,6 @@ def get_long_path_name(path):
return _get_long_path_name(path)
-def unquote_filename(name, win32=(sys.platform=='win32')):
- """ On Windows, remove leading and trailing quotes from filenames.
-
- This function has been deprecated and should not be used any more:
- unquoting is now taken care of by :func:`IPython.utils.process.arg_split`.
- """
- warn("'unquote_filename' is deprecated since IPython 5.0 and should not "
- "be used anymore", DeprecationWarning, stacklevel=2)
- if win32:
- if name.startswith(("'", '"')) and name.endswith(("'", '"')):
- name = name[1:-1]
- return name
-
-
def compress_user(path):
"""Reverse of :func:`os.path.expanduser`
"""
@@ -89,7 +75,7 @@ def compress_user(path):
path = "~" + path[len(home):]
return path
-def get_py_filename(name, force_win32=None):
+def get_py_filename(name):
"""Return a valid python filename in the current directory.
If the given name is not a file, it adds '.py' and searches again.
@@ -97,10 +83,6 @@ def get_py_filename(name, force_win32=None):
"""
name = os.path.expanduser(name)
- if force_win32 is not None:
- warn("The 'force_win32' argument to 'get_py_filename' is deprecated "
- "since IPython 5.0 and should not be used anymore",
- DeprecationWarning, stacklevel=2)
if not os.path.isfile(name) and not name.endswith('.py'):
name += '.py'
if os.path.isfile(name):
@@ -109,7 +91,7 @@ def get_py_filename(name, force_win32=None):
raise IOError('File `%r` not found.' % name)
-def filefind(filename, path_dirs=None):
+def filefind(filename: str, path_dirs=None) -> str:
"""Find a file by looking through a sequence of paths.
This iterates through a sequence of paths looking for a file and returns
@@ -139,7 +121,12 @@ def filefind(filename, path_dirs=None):
Returns
-------
- Raises :exc:`IOError` or returns absolute path to file.
+ path : str
+ returns absolute path to file.
+
+ Raises
+ ------
+ IOError
"""
# If paths are quoted, abspath gets confused, strip them...
@@ -178,7 +165,6 @@ def get_home_dir(require_writable=False) -> str:
Parameters
----------
-
require_writable : bool [default: False]
if True:
guarantees the return value is a writable directory, otherwise
@@ -205,7 +191,7 @@ def get_home_dir(require_writable=False) -> str:
pass
if (not require_writable) or _writable_dir(homedir):
- assert isinstance(homedir, str), "Homedir shoudl be unicode not bytes"
+ assert isinstance(homedir, str), "Homedir should be unicode not bytes"
return homedir
else:
raise HomeDirError('%s is not a writable dir, '
@@ -219,7 +205,7 @@ def get_xdg_dir():
env = os.environ
- if os.name == 'posix' and sys.platform != 'darwin':
+ if os.name == "posix":
# Linux, Unix, AIX, etc.
# use ~/.config if empty OR not set
xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config')
@@ -238,7 +224,7 @@ def get_xdg_cache_dir():
env = os.environ
- if os.name == 'posix' and sys.platform != 'darwin':
+ if os.name == "posix":
# Linux, Unix, AIX, etc.
# use ~/.cache if empty OR not set
xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache')
@@ -249,36 +235,6 @@ def get_xdg_cache_dir():
return None
-@undoc
-def get_ipython_dir():
- warn("get_ipython_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
- from IPython.paths import get_ipython_dir
- return get_ipython_dir()
-
-@undoc
-def get_ipython_cache_dir():
- warn("get_ipython_cache_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
- from IPython.paths import get_ipython_cache_dir
- return get_ipython_cache_dir()
-
-@undoc
-def get_ipython_package_dir():
- warn("get_ipython_package_dir has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
- from IPython.paths import get_ipython_package_dir
- return get_ipython_package_dir()
-
-@undoc
-def get_ipython_module_path(module_str):
- warn("get_ipython_module_path has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
- from IPython.paths import get_ipython_module_path
- return get_ipython_module_path(module_str)
-
-@undoc
-def locate_profile(profile='default'):
- warn("locate_profile has moved to the IPython.paths module since IPython 4.0.", DeprecationWarning, stacklevel=2)
- from IPython.paths import locate_profile
- return locate_profile(profile=profile)
-
def expand_path(s):
"""Expand $VARS and ~names in a string, like a shell