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 ofself._fileto 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
filetoseekset, then call the decorated function and returns its return value.Note
The decorated function should have following signature:
func(file, *args, seekset=os.SEEK_SET, **kw)
See also
-
@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 theself._fileasRawprotocol.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 thefileasRawprotocol.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.