API Documentation

exception nukecontexts.ctx.NukeContextError(message, *args)[source]
nukecontexts.ctx.disabled(*args, **kwds)[source]

Given a list of nodes (Node), disable on entry and restore to original value on exit.

Parameters:
nukecontexts.ctx.enabled(*args, **kwds)[source]

Given a list of nodes (Node), enable on entry and restore to original value on exit.

Parameters:
nukecontexts.ctx.inventory(*args, **kwds)[source]

Given a variable name, create a node inventory on entry and a separate node inventory on exit and save any new nodes into the newly created variable.

Beware that the new variable is created in __builtins__ and is therefore accessible even after the context manager has exited.

Use with namespace in mind!

Parameters:var (str) – Variable name
nukecontexts.ctx.multiple_contexts(*args, **kwds)[source]

Given a list of contextmanagers, sequentially enter all contextmanagers, raise Exception in case errors occur in contexts.

Deprecated. Use contextlib.nested(*contexts)().

Parameters:contexts (list) – List of contextmanagers
nukecontexts.ctx.set_attr(*args, **kwds)[source]

Given a list of nodes (Node), set a given attr to value on entry and restore to original value on exit.

Parameters:
class nukecontexts.ctx.Progress(iterable, name='nukecontexts', output=<open file '<stdout>', mode 'w'>)[source]

Convenience wrapper class around tqdm.tqdm() for easy progress bars

Usage:

>>> with Progress(iterable) as progress:
>>>    for item in progress:
>>>        #do something
__init__(iterable, name='nukecontexts', output=<open file '<stdout>', mode 'w'>)[source]
Parameters:
  • interable (iter) – Iterable to generate progress bar for
  • name (str) – Progress bar label (default: ‘nukecontexts’)
  • output (io.TextIOWrapper or io.StringIO) – Output stream (default: sys.stdout)
class nukecontexts.ctx.AttributeSetter(nodes, attr, value, log=<logging.RootLogger object>)[source]
__init__(nodes, attr, value, log=<logging.RootLogger object>)[source]

Given a list of nodes (Node), set a given attr to value on entry and restore to original value on exit.

Parameters: