SEPUtils¶
- Author
Marcel Simader
- Date
01.08.2021
New in version v2.0.0.
Exceptions¶
- exception SEPModules.SEPUtils.SEPSyntaxError(msg, file_path, lineno, offset, code_context)¶
SEPSyntaxErroris an error for general syntax errors raised by custom implementations inSEPModules.- Parameters
msg (AnyStr) – the message of the error
file_path (Union[AnyStr, os.PathLike]) – the path to the file where the error occurred
lineno (int) – the line number at which the error occurred in the file
offset (int) – the offset in characters for the syntax error ‘cursor’
code_context (List[AnyStr]) – the code context of where the error occurred (i.e. the source code)
- static from_traceback(msg, tb, offset=0)¶
Creates a
SEPSyntaxErrorobject from a message, traceback, and an optional offset.- Parameters
msg (AnyStr) – the message of the error
tb (inspect.Traceback) – the traceback to use as basis for the error
offset (int) – the offset in characters for the syntax error ‘cursor’
- Returns
a new
SEPSyntaxErrorinstance- Return type
Immutable¶
- class SEPModules.SEPUtils.ImmutableMeta(*args, **kwargs)¶
ImmutableMetais the meta class behind the mechanism of theImmutableabstract base class.
Singleton¶
- class SEPModules.SEPUtils.SingletonMeta(*args, **kwargs)¶
SingletonMetais the meta class behind the mechanics of theSingletonabstract base class.
- class SEPModules.SEPUtils.Singleton(*args, **kwargs)¶
Singletonis an abstract base class that can be inherited from in order to indicate that a class should be a singleton class. A singleton class can only be instantiated once, and once that instance has been created it is immutable.The singleton instance can be retrieved from the class object by calling the
get_instance()class method. It may beNoneif no instance of the class has been created yet.- final classmethod get_instance()¶
Retrieve the singleton instance of this singleton class, or
Noneif it has not been instantiated yet.
Stack Frame Info¶
- class SEPModules.SEPUtils.StackFrameInfo(_StackFrameInfo__offset=2)¶
StackFrameInfois a convenient way to safely retrieveTracebackobjects from the stack. It only implements three methods (__init__,get_tracebacks, and__getitem__) to retrieve the tracebacks and emulate a container type with its syntax. Note that it is not actually a container type!Its usage is shown in the following example:
for tb in StackFrameInfo()[:2]: print(tb.lineno)
- Parameters
__offset – how much to offset the start of the stack, this only affects the container syntax, defaults to 2
- class SEPModules.SEPUtils.SingleStackFrameInfo(_StackFrameInfo__offset=2)¶
SingleStackFrameInfois a special case ofStackFrameInfowhich only returns a single traceback instead of a tuple. SeeStackFrameInfofor more details.