TotalDepth.LIS.core.Mnem (Mnemonics)

Represents a MNEM (Mnemonic) as bytes. Created on May 26, 2011

@author: paulross

TotalDepth.LIS.core.Mnem.ORDS_WS = (32, 9, 10, 13, 11, 12)

A tuple of the ordinal values of whitespace characters

TotalDepth.LIS.core.Mnem.ORDS_REPLACE = (0, 32, 9, 10, 13, 11, 12)

A tuple of the ordinal values of characters that can be replaced with PAD_CHAR

TotalDepth.LIS.core.Mnem.LEN_MNEM = 4

Standard LIS mnemonic length

class TotalDepth.LIS.core.Mnem.Mnem(m, len_mnem=4)

Represents a four byte mnemonic where tailing nulls and spaces are not considered significant. This preserves original length but replaces trailing and whitespace characters with the PAD_CHAR.

m must be a bytes object or an ‘ascii’ str that can be converted to a bytes object.

If len_mnem is positive then m is truncated or padded as necessary to achieve that length.

If len_mnem is zero then all of m is considered significant, no padding is performed.

If len_mnem is less than zero then all characters of m are considered significant and padding up to -1*len_mnem characters of m is performed if m smaller than that.

__init__(m, len_mnem=4)

Constructor that prunes trailing nulls and spaces.

m

The raw bytes of the mnemonic.

__str__()

String representation.

pStr(strip=False)

Returns a ‘pretty’ ascii string. If strip then trailing padding is removed.

__repr__()

repr() representation.

__hash__()

Hashing, this makes bytes() and Mnem() objects interchangeable.

__eq__(other)

True if self == other False otherwise. If other is not a Mnem it is coerced into one before the comparison is made..

__ne__(other)

True if self != other False otherwise. If other is not a Mnem it is coerced into one before the comparison is made..

__lt__(other)

True if self < other False otherwise. If other is not a Mnem it is coerced into one before the comparison is made..

__iter__()

Byte by byte iteration.

__weakref__

list of weak references to the object (if defined)