:py:mod:`path` ============== .. py:module:: conda.common.path .. autoapi-nested-parse:: Common path utilities. Functions --------- .. autoapisummary:: conda.common.path.is_path conda.common.path.expand conda.common.path.paths_equal conda.common.path.url_to_path conda.common.path.tokenized_startswith conda.common.path.get_all_directories conda.common.path.get_leaf_directories conda.common.path.explode_directories conda.common.path.pyc_path conda.common.path.missing_pyc_files conda.common.path.parse_entry_point_def conda.common.path.get_python_short_path conda.common.path.get_python_site_packages_short_path conda.common.path.get_major_minor_version conda.common.path.get_bin_directory_short_path conda.common.path.win_path_ok conda.common.path.win_path_double_escape conda.common.path.win_path_backout conda.common.path.ensure_pad conda.common.path.is_private_env_name conda.common.path.is_private_env_path conda.common.path.right_pad_os_sep conda.common.path.split_filename conda.common.path.get_python_noarch_target_path conda.common.path.win_path_to_unix conda.common.path.which conda.common.path.strip_pkg_extension conda.common.path.is_package_file Attributes ---------- .. autoapisummary:: conda.common.path.PATH_MATCH_REGEX conda.common.path.KNOWN_EXTENSIONS conda.common.path._VERSION_REGEX .. py:data:: PATH_MATCH_REGEX :value: '\\./|\\.\\.|~|/|[a-zA-Z]:[/\\\\]|\\\\\\\\|//' .. py:data:: KNOWN_EXTENSIONS :value: ('.conda', '.tar.bz2', '.json', '.jlap', '.json.zst') .. py:function:: is_path(value) .. py:function:: expand(path) .. py:function:: paths_equal(path1, path2) .. rubric:: Examples >>> paths_equal('/a/b/c', '/a/b/c/d/..') True .. py:function:: url_to_path(url) Convert a file:// URL to a path. Relative file URLs (i.e. `file:relative/path`) are not supported. .. py:function:: tokenized_startswith(test_iterable, startswith_iterable) .. py:function:: get_all_directories(files: Iterable[str]) -> list[tuple[str]] .. py:function:: get_leaf_directories(files: Iterable[str]) -> Sequence[str] .. py:function:: explode_directories(child_directories: Iterable[tuple[str, Ellipsis]]) -> set[str] .. py:function:: pyc_path(py_path, python_major_minor_version) This must not return backslashes on Windows as that will break tests and leads to an eventual need to make url_to_path return backslashes too and that may end up changing files on disc or to the result of comparisons with the contents of them. .. py:function:: missing_pyc_files(python_major_minor_version, files) .. py:function:: parse_entry_point_def(ep_definition) .. py:function:: get_python_short_path(python_version=None) .. py:function:: get_python_site_packages_short_path(python_version) .. py:data:: _VERSION_REGEX .. py:function:: get_major_minor_version(string, with_dot=True) .. py:function:: get_bin_directory_short_path() .. py:function:: win_path_ok(path) .. py:function:: win_path_double_escape(path) .. py:function:: win_path_backout(path) .. py:function:: ensure_pad(name, pad='_') .. rubric:: Examples >>> ensure_pad('conda') '_conda_' >>> ensure_pad('_conda') '__conda_' >>> ensure_pad('') '' .. py:function:: is_private_env_name(env_name) .. rubric:: Examples >>> is_private_env_name("_conda") False >>> is_private_env_name("_conda_") True .. py:function:: is_private_env_path(env_path) .. rubric:: Examples >>> is_private_env_path('/some/path/to/envs/_conda_') True >>> is_private_env_path('/not/an/envs_dir/_conda_') False .. py:function:: right_pad_os_sep(path) .. py:function:: split_filename(path_or_url) .. py:function:: get_python_noarch_target_path(source_short_path, target_site_packages_short_path) .. py:function:: win_path_to_unix(path, root_prefix='') .. py:function:: which(executable) Backwards-compatibility wrapper. Use `shutil.which` directly if possible. .. py:function:: strip_pkg_extension(path: str) .. rubric:: Examples >>> strip_pkg_extension("/path/_license-1.1-py27_1.tar.bz2") ('/path/_license-1.1-py27_1', '.tar.bz2') >>> strip_pkg_extension("/path/_license-1.1-py27_1.conda") ('/path/_license-1.1-py27_1', '.conda') >>> strip_pkg_extension("/path/_license-1.1-py27_1") ('/path/_license-1.1-py27_1', None) .. py:function:: is_package_file(path) .. rubric:: Examples >>> is_package_file("/path/_license-1.1-py27_1.tar.bz2") True >>> is_package_file("/path/_license-1.1-py27_1.conda") True >>> is_package_file("/path/_license-1.1-py27_1") False