Module osyspyrt.util

General utility functions.

Functions

def group(a, *ns)
def hexdump(data)
def is_integer(value)

Return true if the given string consists of one or more digits, 0-9. This differs from built-in functions which recognize other characters that Unicode designates as digits, and it does not allow for whitespace.

def join(a, *cs)
def lowest_set(val)

Return the lowest bit set in the given value.

Parameters

val : int
A value > 0.

Returns

int
The lowest bit set. 0 for the least significant bit.

Raises

ValueError if val == 0
def signed_bytes(value)

Return the minimal signed, 2's complement representation for the given value. For zero, this will be a bytes object of length 1.

Parameters

value : int
 

Returns

bytes
 
def tbcd_bin_to_str(value)

Convert a TBCD binary representation to a TBCD character string, following 3GPP 29.002.

Parameters

value : bytes or bytearray
 

Raises

ValueError if the not a valid TBCD binary representation.

def tbcd_digit_to_char(digit)

Convert a TBCD digit to TBCD char, following 3GPP 29.002. 0xF is converted to empty string. ValueError is raised if digit is not between 0x0 and 0xF.

def tbcd_str_to_bin(value)

Convert the given TBCD character string to binary, following 3GPP 29.002.

Returns

bytearray
 
def unsigned_bytes(value)

Return the minimal unsigned representation for the given value. For zero, this will be a bytes object of length 1.

Parameters

value : int
A value >= 0

Returns

bytes