kitty.model.low_level.encoder module¶
Encoders are used for encoding fields and containers. The encoders are passed as an argument to the fields/container, during the field rendering, the encoder’s encode method is called.
There are four families of encoders:
| Bits Encoders: | Used to encode fields/containers that their value is of type Bits (Container, ForEach etc.) |
|---|---|
| String Encoders: | |
| Used to encode fields that their value is of type str (String, Delimiter, RandomBytes etc.) | |
| BitField Encoders: | |
| Used to encode fields that inherit from BitField or contain BitField (UInt8, Size, Checksum etc.) Those encoders are also refferred to as Int Encoders. | |
| FloatingPoint Encoders: | |
| Used to encode fields that inherit from FloatingPoint field (Float, Double) Those encoders are also refferred to as Float Encoders | |
-
class
kitty.model.low_level.encoder.BitFieldAsciiEncoder(fmt)[source]¶ Bases:
kitty.model.low_level.encoder.BitFieldEncoderEncode int as ascii
-
formats= ['%d', '%x', '%X', '%#x', '%#X']¶
-
-
class
kitty.model.low_level.encoder.BitFieldBinEncoder(mode)[source]¶ Bases:
kitty.model.low_level.encoder.BitFieldEncoderEncode int as binary
-
class
kitty.model.low_level.encoder.BitFieldEncoder[source]¶ Bases:
objectBase encoder class for BitField values
Singleton Name Encoding Class ENC_INT_BIN Encode as binary bits BitFieldBinEncoder ENC_INT_LE Encode as a little endian binary bits ENC_INT_BE Encode as a big endian binary bits ENC_INT_DEC Encode as a decimal value BitFieldAsciiEncoder ENC_INT_HEX Encode as a hex value ENC_INT_HEX_UPPER Encode as an upper case hex value ENC_INT_DEFAULT Same as ENC_INT_BIN BitFieldBinEncoder
-
class
kitty.model.low_level.encoder.BitFieldMultiByteEncoder(mode='be')[source]¶ Bases:
kitty.model.low_level.encoder.BitFieldEncoderEncode int as multi-byte (used in WBXML format)
-
class
kitty.model.low_level.encoder.BitsEncoder[source]¶ Bases:
objectBase encoder class for Bits values
The Bits encoders encode function receives a Bits object as an argument and returns an encoded Bits object.
Singleton Name Encoding Class ENC_BITS_NONE None, returns the same value received BitsEncoder ENC_BITS_BYTE_ALIGNED Appends bits to the received object to make it byte aligned ByteAlignedBitsEncoder ENC_BITS_REVERSE Reverse the order of bits ReverseBitsEncoder ENC_BITS_BASE64 Encode a Byte aligned bits in base64 StrEncoderWrapper ENC_BITS_BASE64_NO_NL Encode a Byte aligned bits in base64, but removes the new line from the end ENC_BITS_UTF8 Encode a Byte aligned bits in UTF-8 ENC_BITS_HEX Encode a Byte aligned bits in hex ENC_BITS_DEFAULT Same as ENC_BITS_NONE
-
class
kitty.model.low_level.encoder.BitsFuncEncoder(func)[source]¶ Bases:
kitty.model.low_level.encoder.BitsEncoderEncode bits using a given function
-
class
kitty.model.low_level.encoder.ByteAlignedBitsEncoder[source]¶ Bases:
kitty.model.low_level.encoder.BitsEncoderStuff bits for byte alignment
-
class
kitty.model.low_level.encoder.FloatAsciiEncoder(fmt)[source]¶ Bases:
kitty.model.low_level.encoder.FloatEncoderEncode a floating point number in ascii as described by IEEE 754 (decimal*)
-
class
kitty.model.low_level.encoder.FloatBinEncoder(fmt)[source]¶ Bases:
kitty.model.low_level.encoder.FloatEncoderEncode a floating point number in binary format as described by IEEE 754 (binary32 and binary64)
-
class
kitty.model.low_level.encoder.FloatEncoder[source]¶ Bases:
objectBase encoder class for FloatingPoint values
Singleton Name Encoding Class ENC_FLT_LE Encode as a little endian 32 bit FloatBinEncoderENC_FLT_BE Encode as a big endian 32 bit ENC_DBL_LE Encode as a little endian 64 bit ENC_DBL_BE Encode as a big endian 64 bit ENC_FLT_FP Fixed point FloatAsciiEncoderENC_FLT_EXP Exponent notation ENC_FLT_EXP_UPPER Exponent notation, with upper case E ENC_FLT_GEN General format ENC_FLT_GEN_UPPER General format, with upper case ENC_FLT_DEFAULT Same as ENC_FLT_BE FloatBinEncoder
-
class
kitty.model.low_level.encoder.ReverseBitsEncoder[source]¶ Bases:
kitty.model.low_level.encoder.BitsEncoderReverse the order of bits
-
class
kitty.model.low_level.encoder.StrBase64NoNewLineEncoder[source]¶ Bases:
kitty.model.low_level.encoder.StrEncoderEncode the string as base64, but without the new line at the end
-
class
kitty.model.low_level.encoder.StrEncodeEncoder(encoding)[source]¶ Bases:
kitty.model.low_level.encoder.StrEncoderEncode the string using str.encode function
-
class
kitty.model.low_level.encoder.StrEncoder[source]¶ Bases:
objectBase encoder class for str values The String encoders encode function receives a str object as an argument and returns an encoded Bits object.
Singleton Name Encoding Class ENC_STR_UTF8 Encode the str in UTF-8 StrEncodeEncoder ENC_STR_HEX Encode the str in hex ENC_STR_BASE64 Encode the str in base64 ENC_STR_BASE64_NO_NL Encode the str in base64 but remove the new line from the end StrBase64NoNewLineEncoder ENC_STR_DEFAULT Do nothing, just convert the str to Bits object StrEncoder
-
class
kitty.model.low_level.encoder.StrEncoderWrapper(encoder)[source]¶ Bases:
kitty.model.low_level.encoder.ByteAlignedBitsEncoderEncode the data using str.encode function
-
__init__(encoder)[source]¶ Parameters: encoding (StrEncoder) – encoder to wrap
-
-
class
kitty.model.low_level.encoder.StrFuncEncoder(func)[source]¶ Bases:
kitty.model.low_level.encoder.StrEncoderEncode string using a given function
-
class
kitty.model.low_level.encoder.StrNullTerminatedEncoder[source]¶ Bases:
kitty.model.low_level.encoder.StrEncoderEncode the string as c-string, with null at the end