Belle II Software
release-08-01-10
|
Classes | |
class | Error |
class | ReadError |
class | InterpretError |
class | ByteAlignError |
class | CreationError |
class | ConstByteStore |
class | ByteStore |
class | MmapByteArray |
class | Bits |
class | BitArray |
class | ConstBitStream |
class | BitStream |
Functions | |
def | offsetcopy (s, newoffset) |
def | equal (a, b) |
def | tidy_input_string (s) |
def | structparser (token) |
def | tokenparser (fmt, keys=None, token_cache=None) |
def | expand_brackets (s) |
def | pack (fmt, *values, **kwargs) |
Variables | |
string | __licence__ |
string | __version__ = "3.1.5" |
string | __author__ = "Scott Griffiths" |
byteorder = sys.byteorder | |
bool | bytealigned = False |
int | MAX_CHARS = 250 |
int | CACHE_SIZE = 1000 |
BYTE_REVERSAL_DICT = dict() | |
xrange = range | |
basestring = str | |
int | LEADING_OCT_CHARS = len(oct(1)) - 1 |
tuple | INIT_NAMES |
TOKEN_RE | |
DEFAULT_UINT = re.compile(r'(?P<len>[^=]+)?(=(?P<value>.*))?$', re.IGNORECASE) | |
MULTIPLICATIVE_RE = re.compile(r'(?P<factor>.*)\*(?P<token>.+)') | |
LITERAL_RE = re.compile(r'(?P<name>0(x|o|b))(?P<value>.+)', re.IGNORECASE) | |
STRUCT_PACK_RE = re.compile(r'(?P<endian><|>|@)?(?P<fmt>(?:\d*[bBhHlLqQfd])+)$') | |
STRUCT_SPLIT_RE = re.compile(r'\d*[bBhHlLqQfd]') | |
dictionary | REPLACEMENTS_BE |
dictionary | REPLACEMENTS_LE |
dictionary | PACK_CODE_SIZE |
dictionary | _tokenname_to_initialiser |
BRACKET_RE = re.compile(r'(?P<factor>\d+)\*\(') | |
list | OCT_TO_BITS = ['{0:03b}'.format(i) for i in xrange(8)] |
BIT_COUNT = dict(zip(xrange(256), [bin(i).count('1') for i in xrange(256)])) | |
dictionary | name_to_read |
dictionary | init_with_length_and_offset |
dictionary | init_with_length_only |
dictionary | init_without_length_or_offset |
ConstBitArray = Bits | |
BitString = BitStream | |
list | __all__ |
This package defines classes that simplify bit-wise creation, manipulation and interpretation of data. Classes: Bits -- An immutable container for binary data. BitArray -- A mutable container for binary data. ConstBitStream -- An immutable container with streaming methods. BitStream -- A mutable container with streaming methods. Bits (base class) / \ + mutating methods / \ + streaming methods / \ BitArray ConstBitStream \ / \ / \ / BitStream Functions: pack -- Create a BitStream from a format string. Exceptions: Error -- Module exception base class. CreationError -- Error during creation. InterpretError -- Inappropriate interpretation of binary data. ByteAlignError -- Whole byte position or length needed. ReadError -- Reading or peeking past the end of a bitstring. https://github.com/scott-griffiths/bitstring
def scripts.bitstring.equal | ( | a, | |
b | |||
) |
Return True if ByteStores a == b. Not part of public interface.
Definition at line 292 of file bitstring.py.
def scripts.bitstring.expand_brackets | ( | s | ) |
Remove whitespace and expand all brackets.
Definition at line 648 of file bitstring.py.
def scripts.bitstring.offsetcopy | ( | s, | |
newoffset | |||
) |
Return a copy of a ByteStore with the newoffset. Not part of public interface.
Definition at line 250 of file bitstring.py.
def scripts.bitstring.pack | ( | fmt, | |
* | values, | ||
** | kwargs | ||
) |
Pack the values according to the format string and return a new BitStream. fmt -- A single string or a list of strings with comma separated tokens describing how to create the BitStream. values -- Zero or more values to pack according to the format. kwargs -- A dictionary or keyword-value pairs - the keywords used in the format string will be replaced with their given value. Token examples: 'int:12' : 12 bits as a signed integer 'uint:8' : 8 bits as an unsigned integer 'float:64' : 8 bytes as a big-endian float 'intbe:16' : 2 bytes as a big-endian signed integer 'uintbe:16' : 2 bytes as a big-endian unsigned integer 'intle:32' : 4 bytes as a little-endian signed integer 'uintle:32' : 4 bytes as a little-endian unsigned integer 'floatle:64': 8 bytes as a little-endian float 'intne:24' : 3 bytes as a native-endian signed integer 'uintne:24' : 3 bytes as a native-endian unsigned integer 'floatne:32': 4 bytes as a native-endian float 'hex:80' : 80 bits as a hex string 'oct:9' : 9 bits as an octal string 'bin:1' : single bit binary string 'ue' / 'uie': next bits as unsigned exp-Golomb code 'se' / 'sie': next bits as signed exp-Golomb code 'bits:5' : 5 bits as a bitstring object 'bytes:10' : 10 bytes as a bytes object 'bool' : 1 bit as a bool 'pad:3' : 3 zero bits as padding >>> s = pack('uint:12, bits', 100, '0xffe') >>> t = pack(['bits', 'bin:3'], s, '111') >>> u = pack('uint:8=a, uint:8=b, uint:55=a', a=6, b=44)
Definition at line 4170 of file bitstring.py.
def scripts.bitstring.structparser | ( | token | ) |
Parse struct-like format string token into sub-token list.
Definition at line 511 of file bitstring.py.
def scripts.bitstring.tidy_input_string | ( | s | ) |
Return string made lowercase and with all whitespace removed.
Definition at line 463 of file bitstring.py.
def scripts.bitstring.tokenparser | ( | fmt, | |
keys = None , |
|||
token_cache = None |
|||
) |
Divide the format string into tokens and parse them. Return stretchy token and list of [initialiser, length, value] initialiser is one of: hex, oct, bin, uint, int, se, ue, 0x, 0o, 0b etc. length is None if not known, as is value. If the token is in the keyword dictionary (keys) then it counts as a special case and isn't messed with. tokens must be of the form: [factor*][initialiser][:][length][=value]
Definition at line 540 of file bitstring.py.
|
private |
Definition at line 4249 of file bitstring.py.
|
private |
Definition at line 39 of file bitstring.py.
|
private |
Definition at line 506 of file bitstring.py.
tuple INIT_NAMES |
Definition at line 469 of file bitstring.py.
dictionary init_with_length_and_offset |
Definition at line 2920 of file bitstring.py.
dictionary init_with_length_only |
Definition at line 2924 of file bitstring.py.
dictionary init_without_length_or_offset |
Definition at line 2938 of file bitstring.py.
dictionary name_to_read |
Definition at line 2895 of file bitstring.py.
dictionary PACK_CODE_SIZE |
Definition at line 503 of file bitstring.py.
dictionary REPLACEMENTS_BE |
Definition at line 490 of file bitstring.py.
dictionary REPLACEMENTS_LE |
Definition at line 496 of file bitstring.py.
TOKEN_RE |
Definition at line 473 of file bitstring.py.