Base Engine¶
This is the abstract base class implementation for all engine support functionality.
- class pcapkit.foundation.engines.engine.Engine(extractor)[source]¶
Bases:
EngineBase
[_T
],Generic
[_T
]Base class for engine support.
Example
Use keyword argument
name
to specify the engine name at class definition:class MyEngine(Engine, name='my_engine'): ...
See also
For more information on customisation and extension, please refer to Customisation & Extensions.
- property name: str¶
Engine name.
Note
This property is also available as a class variable. Its value can be set by
__engine_name__
class attribute.
- property module: str¶
Engine module name.
Note
This property is also available as a class variable. Its value can be set by
__engine_module__
class attribute.
- abstract run()¶
Start extraction.
This method is the entry point for file extraction. It is to be used for preparing the extraction process, such as parsing the file header and setting up the extraction engines.
- Return type:
- abstract read_frame()¶
Read frame.
This method is to be used for reading a frame from the file. It is to read a frame from the file using the prepared engine instance and return the parsed frame.
- Return type:
TypeVar
(_T
)
- close()¶
Close engine.
This method is to be used for closing the engine instance. It is to close the engine instance after the extraction process is finished.
- Return type:
- __call__()¶
Start extraction.
This method will directly call
run()
to start the extraction process.- Return type:
- classmethod __init_subclass__(name=None, *args, **kwargs)[source]¶
Initialise subclass.
This method is to be used for registering the engine class to
Extractor
class.- Parameters:
- Return type:
See also
For more details, please refer to
pcapkit.foundation.extraction.Extractor.register_engine()
.
Internal Definitions¶
- class pcapkit.foundation.engines.engine.EngineBase(extractor)[source]¶
-
Base class for engine support.
Note
This class is for internal use only. For customisation, please use
Engine
instead.
- class pcapkit.foundation.engines.engine.EngineMeta(name, bases, namespace, /, **kwargs)[source]¶
-
Meta class to add dynamic support to
EngineBase
.This meta class is used to generate necessary attributes for the
EngineBase
class. It can be useful to reduce unnecessary registry calls and simplify the customisation process.