dynamic_executor package

Subpackages

Module contents

class dynamic_executor.DynamicClass(*args, **kwargs)[source]

Bases: object

Abstract class that is to be extended in order to implement instance tracking polity that allows instance runtime updates.

created_classes: List[DynamicClassCreator] = [<class 'dynamic_executor.classes.DynamicClassModule.DynamicClass'>]
class dynamic_executor.DynamicClassCreator(name, bases, namespace)[source]

Bases: type

Metaclass that makes classes track their instances and stores them.

Created to update methods and class fields of dynamic class instances as the classes change.

created_classes: List[DynamicClassCreator] = [<class 'dynamic_executor.classes.DynamicClassModule.DynamicClass'>]
class dynamic_executor.DynamicModeExecutor(executor_path: Path = PosixPath('executor.py'), finish_upon_success: bool = True, supress_print: bool = False)[source]

Bases: object

A main component of dynamic execution loop. Creates executor file with access to local and global variables where code can be safely executed.

for error in DynamicModeExecutor().execute(locals(), globals()):

pass

With each iteration modules are reloaded and the changes applied to DynamicClass instances.

execute(local_vars: Dict, global_vars: Dict, executor_path: Path = None, finish_upon_success: bool = None, supress_print: bool = None) Generator[str, None, None][source]

Method used to override class parameters and accept local and global parameters.

Parameters:
  • local_vars – local variables that can be a subject to change usually locals().

  • global_vars – global variables that can be a subject to change usually global().

  • executor_path – A path to an executor file, defaults to one in self.

  • finish_upon_success – Specifies if there should be any iterations after a successful execution. Defaults to a value in self.

  • supress_print – Manages exception printing. If True exception is printed as if it occurred during an uncontrolled runtime. Exception is always yielded by loop not matter the argument.

Returns:

Error message if one occurred during execution. None otherwise.