set_global_supercontext

set_global_supercontext#

class processor_tools.context.set_global_supercontext(supercontext: Tuple[Context, str] | Context)[source]#

Sets a context object to become a global supercontext for other context objects

Parameters:

context

supercontext defined as context object or tuple of:

  • supercontext (Context) - supercontext object

  • section (str) - name of section of supercontext to apply as supercontext

For example:

supercontext = Context({"section": {"val1": 1 , "val2", 2}})
(supercontext, "section")

Can be run with a with statement, as follows

from processor_tools import Context, set_global_supercontext

my_context = Context()
with set_global_supercontext(my_context):
    run_process()

In this example, my_context is set as the global supercontext within the scope of the with statement and then removed after.

Methods