Dump Utilities

pcapkit.dumpkit is the collection of dumpers for pcapkit implementation, which is alike those described in dictdumper.

PCAP Dumper

class pcapkit.dumpkit.PCAP(fname, *, protocol, byteorder='little', nanosecond=False, **kwargs)[source]

Bases: dictdumper.dumper.Dumper

PCAP file dumper.

__call__(value, name=None)[source]

Dump a new frame.

Parameters
  • value (Info[DataType_Frame]) – content to be dumped

  • name (Optional[str]) – name of current content block

Returns

the dumper class itself (to support chain calling)

Return type

PCAP

__init__(fname, *, protocol, byteorder='little', nanosecond=False, **kwargs)[source]

Initialise dumper.

Parameters

fname (str) – output file name

Keyword Arguments
_append_value(value, file, name)[source]

Call this function to write contents.

Parameters
_dump_header(*, protocol, byteorder='little', nanosecond=False, **kwargs)[source]

Initially dump file heads and tails.

Keyword Arguments
_fnum = None

Frame counter.

Type

int

Data link type.

Type

Union[pcapkit.const.reg.linktype.LinkType, enum.IntEnum, str, int]

_nsec = None

Nanosecond-resolution file flag.

Type

bool

property kind

File format of current dumper.

Return type

Literal[‘pcap’]

Undefined Dumper

class pcapkit.dumpkit.NotImplementedIO(fname, **kwargs)[source]

Bases: dictdumper.dumper.Dumper

Unspecified output format.

__call__(value, name=None)[source]

Dump a new frame.

Parameters
  • value (Dict[str, Any]) – content to be dumped

  • name (Optional[str]) – name of current content block

Returns

the dumper class itself (to support chain calling)

Return type

PCAP

_append_value(value, file, name)[source]

Call this function to write contents.

Parameters
  • value (Dict[str, Any]) – content to be dumped

  • file (io.TextIOWrapper) – output file

  • name (str) – name of current content block

_dump_header(**kwargs)[source]

Initially dump file heads and tails.

Keyword Arguments

**kwargs – arbitrary keyword arguments

property kind

File format of current dumper.

Return type

Literal[NotImplemented]