rez.util

Misc useful stuff. TODO: Move this into rez.utils.?

class rez.util.ProgressBar

Bases: Bar

__init__(label, max) None
file = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
hide_cursor = True
bar_prefix = ' |'
bar_suffix = '| '
check_tty = True
color = None
property elapsed
property elapsed_td
empty_fill = ' '
property eta
property eta_td
fill = '#'
finish()
goto(index)
is_tty()
iter(it)
next(n=1)
property percent
property progress
property remaining
sma_window = 10
start()
suffix = '%(index)d/%(max)d'
update()
update_avg(n, dt)
width = 32
writeln(line)
rez.util.dedup(seq)

Remove duplicates from a list while keeping order.

rez.util.shlex_join(value: Iterable[str], unsafe_regex=None, replacements: Iterable[tuple[str | Pattern[str], str]] | None = None, enclose_with: str = '"') str

Join args into a valid shell command.

rez.util.which(*programs, **shutilwhich_kwargs) str | None
rez.util.get_close_matches(term: str, fields, fuzziness: float = 0.4, key=None)
rez.util.get_close_pkgs(pkg, pkgs, fuzziness: float = 0.4)
rez.util.find_last_sublist(list_, sublist)

Given a list, find the last occurance of a sublist within it.

Returns:

Index where the sublist starts, or None if there is no match.

rez.util.is_non_string_iterable(arg: str | Iterable[str] | None) TypeGuard[Iterable[str]]

Python 2 and 3 compatible non-string iterable identifier

rez.util.get_function_arg_names(func)

Get names of a function’s args.

Gives full list of positional and keyword-only args.

rez.util.load_module_from_file(name: str, filepath: str) ModuleType

Load a python module from a sourcefile.

Parameters:
  • name (str) – Module name.

  • filepath (str) – Python sourcefile.

Returns:

Loaded module.

Return type:

module

rez.util.resolve_variant_indices(variants: list[int], num_variants: int) tuple[set[int], list[int]]

Resolve possibly-negative variant indices to canonical non-negative ones.

Parameters:
  • variants – Requested variant indices (may include negatives).

  • num_variants – Total number of variants in the package.

Returns:

  • resolved (set[int]): Canonical non-negative indices.

  • invalid (list[int]): Any indices outside [-num_variants, num_variants-1], sorted for deterministic error messages. Empty when all indices are valid. When num_variants is 0 the package has no explicit variants; the input is returned unchanged and invalid is always empty.

Return type:

A 2-tuple of