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)

SEPSyntaxError is an error for general syntax errors raised by custom implementations in SEPModules.

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 SEPSyntaxError object 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 SEPSyntaxError instance

Return type

SEPModules.SEPUtils.SEPSyntaxError

Immutable

class SEPModules.SEPUtils.ImmutableMeta(*args, **kwargs)

ImmutableMeta is the meta class behind the mechanism of the Immutable abstract base class.

class SEPModules.SEPUtils.Immutable(*args, **kwargs)

Immutable is an abstract base class for marking the instances of a class to be immutable. This means that once an object has been created, no attributes can be deleted from it or set to another value.

Singleton

class SEPModules.SEPUtils.SingletonMeta(*args, **kwargs)

SingletonMeta is the meta class behind the mechanics of the Singleton abstract base class.

class SEPModules.SEPUtils.Singleton(*args, **kwargs)

Singleton is 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 be None if no instance of the class has been created yet.

final classmethod get_instance()

Retrieve the singleton instance of this singleton class, or None if it has not been instantiated yet.

Stack Frame Info

class SEPModules.SEPUtils.StackFrameInfo(_StackFrameInfo__offset=2)

StackFrameInfo is a convenient way to safely retrieve Traceback objects 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)

SingleStackFrameInfo is a special case of StackFrameInfo which only returns a single traceback instead of a tuple. See StackFrameInfo for more details.

Functions

SEPModules.SEPUtils.abstract_not_implemented(cls, name)

Returns a NotImplementedError to raise for when an abstract method is not implemented for a class.