wasp_general.types package

Submodules

wasp_general.types.binarray module

class wasp_general.types.binarray.WBinArray(value=0, size=None)[source]

Bases: object

This type represent sequence of bit. Bits are ordered as MSB does (most significant bit has index 0). If size is specified, then array became fixed-length array. All actions beyond the limit will be omitted or exception will be raised.

see also https://en.wikipedia.org/wiki/Bit_numbering

concat(array)[source]

Return new fixed-length array, that is made by creating new array with length of sum of two arrays (this array and the given one). In newly created array the most significant bit of the given array will have an index lesser then an index of the least significant bit of this array.

Parameters:array – array to concatenate with
Returns:WBinArray
extend(*array_list)[source]

Concatenate this array with the given arrays. This method doesn’t modify current array. Instead, it creates new one, that have all of arrays. (see WBinArray.concat() method)

Parameters:array_list – list of WBinArray
Returns:newly created WBinArray
static join(*args)[source]

Concatenate all of the given arrays. (see WBinArray.concat() method)

Parameters:args – list of WBinArray
Returns:WBinArray
rconcat(array)[source]

‘Reverse’ concatenation. Works the same as WBinArray.concat(), but in newly created array the most significant bit of the given array will have an index greater then an index of the least significant bit of this array

Parameters:array – array to concatenate with
Returns:WBinArray
resize(size)[source]

Resize current array. If size is None, then array became nonfixed-length array. If new size is less then current size and value, then value will be truncated (lesser significant bits will be truncated).

Parameters:size
Returns:
split(bits_count)[source]

Split array into smaller parts. Each small array is fixed-length WBinArray (length of that array is bits_count).

Parameters:bits_count – array length
Returns:list of WBinArray
swipe()[source]

Mirror current array value in reverse. Bits that had greater index will have lesser index, and vice-versa. This method doesn’t change this array. It creates a new one and return it as a result.

Returns:WBinArray

wasp_general.types.bytearray module

class wasp_general.types.bytearray.WFixedSizeByteArray(size=0, value=None)[source]

Bases: object

This class represent fixed-length byte-array. Where byte is WBinArray. Bytes are ordered as big-endian. It means that the most significant byte has index 0.

see also https://en.wikipedia.org/wiki/Endianness

bin_array()[source]

Return this sequence as list of bytes (WBinArray)

Returns:list of WBinArray
bin_value()[source]

Return this sequence as single big WBinArray

Returns:WBinArray
byte_size = 8

Bits in byte. Derived classed can modify this without breaking the code. Derived class can do this, but why?!

resize(size)[source]

Grow this array to specified length. This array can’t be shrinked

Parameters:size – new length
Returns:None
swipe()[source]

Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn’t change this array. It creates a new one and return it as a result.

Returns:WFixedSizeByteArray

Module contents