Decorator Functions

pcapkit.utilities.decorators contains several useful decorators, including seekset() and beholder().

@pcapkit.utilities.decorators.seekset[source]

Read file from start then set back to original.

Important

This decorator function is designed for decorating class methods.

The decorator will keep the current offset of self._file, then call the decorated function. Afterwards, it will rewind the offset of self._file to the original and returns the return value from the decorated function.

Note

The decorated function should have following signature:

func(self, *args, **kw)
@pcapkit.utilities.decorators.seekset_ng[source]

Read file from start then set back to original.

Important

This decorator function is designed for decorating plain functions.

The decorator will rewind the offset of file to seekset, then call the decorated function and returns its return value.

Note

The decorated function should have following signature:

func(protocol, file, *args, seekset=os.SEEK_SET, **kw)

c.f. pcapkit.foundation.analysis._analyse().

@pcapkit.utilities.decorators.beholder[source]

Behold extraction procedure.

Important

This decorator function is designed for decorating class methods.

This decorate first keep the current offset of self._file, then try to call the decorated function. Should any exception raised, it will re-parse the self._file as Raw protocol.

Note

The decorated function should have following signature:

func(self, proto, length, *args, **kwargs)
@pcapkit.utilities.decorators.beholder_ng[source]

Behold analysis procedure.

Important

This decorator function is designed for decorating plain functions.

This decorate first keep the current offset of file, then try to call the decorated function. Should any exception raised, it will re-parse the file as Raw protocol.

Note

The decorated function should have following signature:

func(file, length, *args, **kwargs)

Important

pcapkit.utilities.decorators.seekset() and pcapkit.utilities.decorators.beholder() are designed for decorating class methods.