utils#

实用函数。

函数#

unix_path_to_win(path[, root_prefix])

将路径或以 :-分隔的路径字符串转换为 Windows 表示形式

win_path_to_cygwin(path)

cygwin_path_to_win(path)

translate_stream(stream, translator)

human_bytes(n)

以更人性化的形式返回字节数 n。

sys_prefix_unfollowed()

由于 conda 作为符号链接仅安装到非 root 环境中

quote_for_shell(*arguments)

正确引用用于命令行传递的参数。

massage_arguments(arguments[, errors])

wrap_subprocess_call(root_prefix, prefix, dev_mode, ...)

get_comspec()

从 envvars 返回 COMSPEC。

ensure_dir_exists(func)

确保返回目录的函数的目录存在

属性#

unix_path_to_win(path, root_prefix='')#

将路径或以 :-分隔的路径字符串转换为 Windows 表示形式

不添加 cygdrive。如果需要,请将 root_prefix 设置为 "/cygdrive"

win_path_to_cygwin(path)#
cygwin_path_to_win(path)#
translate_stream(stream, translator)#
human_bytes(n)#

以更人性化的形式返回字节数 n。

示例

>>> human_bytes(42)
'42 B'
>>> human_bytes(1042)
'1 KB'
>>> human_bytes(10004242)
'9.5 MB'
>>> human_bytes(100000004242)
'93.13 GB'
_UNIX_SHELL_BASE#
_MSYS2_SHELL_BASE#
_SHELLS#
sys_prefix_unfollowed()#

由于 conda 作为符号链接仅安装到非 root 环境中,并且 sys.prefix 遵循符号链接,因此此函数可用于获取“未跟踪”的 sys.prefix。

此值通常与 conda 已符号链接到的环境的前缀相同。需要此值的一个例子是当 conda 在 find_commands.py 中查找外部子命令时

quote_for_shell(*arguments)#

正确引用用于命令行传递的参数。

对于 POSIX,使用 shlex.join,对于 Windows,使用自定义实现来正确转义元字符。

参数:

arguments (list of str) -- 要引用的参数。

返回:

引用的参数。

返回类型:

str

_RE_UNSAFE#
massage_arguments(arguments, errors='assert')#
wrap_subprocess_call(root_prefix, prefix, dev_mode, debug_wrapper_scripts, arguments, use_system_tmp_path=False)#
get_comspec()#

从 envvars 返回 COMSPEC。

确保 COMSPEC envvar 设置为 cmd.exe,如果未设置,则尝试查找。

引发:

KeyError -- COMSPEC 未定义且无法找到。

返回:

COMSPEC 值。

返回类型:

str

ensure_dir_exists(func)#

确保返回 Path 对象(包含目录)的函数的目录存在