utils#
Utility functions.
Functions#
|
Return the number of bytes n in more human readable form. |
Since conda is installed into non-root environments as a symlink only |
|
|
Properly quote arguments for command line passing. |
|
|
|
|
Returns COMSPEC from envvars. |
|
|
Ensures that the directory exists for functions returning |
Attributes#
- human_bytes(n)#
Return the number of bytes n in more human readable form.
Note: Uses SI prefixes (KB, MB, GB) instead of binary prefixes (KiB, MiB, GiB).
Examples
>>> human_bytes(42) '42 B' >>> human_bytes(1042) '1 KB' >>> human_bytes(10004242) '9.5 MB' >>> human_bytes(100000004242) '93.13 GB'
- sys_prefix_unfollowed()#
Since conda is installed into non-root environments as a symlink only and because sys.prefix follows symlinks, this function can be used to get the 'unfollowed' sys.prefix.
This value is usually the same as the prefix of the environment into which conda has been symlinked. An example of when this is necessary is when conda looks for external sub-commands in find_commands.py
- quote_for_shell(*arguments)#
Properly quote arguments for command line passing.
For POSIX uses shlex.join, for Windows uses a custom implementation to properly escape metacharacters.
- Parameters:
arguments -- Arguments to quote.
- Returns:
Quoted arguments.
- _RE_UNSAFE#
- massage_arguments(arguments, errors='assert')#
- wrap_subprocess_call(root_prefix, prefix, dev_mode, debug_wrapper_scripts, arguments: collections.abc.Sequence[str])#
- get_comspec()#
Returns COMSPEC from envvars.
Ensures COMSPEC envvar is set to cmd.exe, if not attempt to find it.
- Raises:
KeyError -- COMSPEC is undefined and cannot be found.
- Returns:
COMSPEC value.
- ensure_dir_exists(func)#
Ensures that the directory exists for functions returning a Path object containing a directory