![]() |
Belle II Software release-09-00-03
|
Classes | |
| class | BitArray |
| class | Bits |
| class | BitStream |
| class | ByteAlignError |
| class | ByteStore |
| class | ConstBitStream |
| class | ConstByteStore |
| class | CreationError |
| class | Error |
| class | InterpretError |
| class | MmapByteArray |
| class | ReadError |
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 | |
| str | __licence__ |
| str | __version__ = "3.1.5" |
| str | __author__ = "Scott Griffiths" |
| sys | byteorder = sys.byteorder |
| bool | bytealigned = False |
| int | MAX_CHARS = 250 |
| int | CACHE_SIZE = 1000 |
| dict | BYTE_REVERSAL_DICT = dict() |
| try : | |
| range | xrange = range |
| str | basestring = str |
| len | LEADING_OCT_CHARS = len(oct(1)) - 1 |
| tuple | INIT_NAMES |
| re | TOKEN_RE |
| re | DEFAULT_UINT = re.compile(r'(?P<len>[^=]+)?(=(?P<value>.*))?$', re.IGNORECASE) |
| re | MULTIPLICATIVE_RE = re.compile(r'(?P<factor>.*)\*(?P<token>.+)') |
| re | LITERAL_RE = re.compile(r'(?P<name>0(x|o|b))(?P<value>.+)', re.IGNORECASE) |
| re | STRUCT_PACK_RE = re.compile(r'(?P<endian><|>|@)?(?P<fmt>(?:\d*[bBhHlLqQfd])+)$') |
| re | STRUCT_SPLIT_RE = re.compile(r'\d*[bBhHlLqQfd]') |
| dict | REPLACEMENTS_BE |
| dict | REPLACEMENTS_LE |
| dict | PACK_CODE_SIZE |
| dict | _tokenname_to_initialiser |
| re | BRACKET_RE = re.compile(r'(?P<factor>\d+)\*\(') |
| list | OCT_TO_BITS = ['{0:03b}'.format(i) for i in xrange(8)] |
| dict | BIT_COUNT = dict(zip(xrange(256), [bin(i).count('1') for i in xrange(256)])) |
| dict | name_to_read |
| dict | init_with_length_and_offset |
| dict | init_with_length_only |
| dict | init_without_length_or_offset |
| Bits | ConstBitArray = Bits |
| BitStream | 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 equal | ( | a, | |
| b | |||
| ) |
Return True if ByteStores a == b. Not part of public interface.
Definition at line 292 of file bitstring.py.
| def expand_brackets | ( | s | ) |
Remove whitespace and expand all brackets.
Definition at line 648 of file bitstring.py.
| def 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 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 structparser | ( | token | ) |
Parse struct-like format string token into sub-token list.
Definition at line 511 of file bitstring.py.
| def tidy_input_string | ( | s | ) |
Return string made lowercase and with all whitespace removed.
Definition at line 463 of file bitstring.py.
| def 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 65 of file bitstring.py.
|
private |
Definition at line 39 of file bitstring.py.
|
private |
Definition at line 63 of file bitstring.py.
|
protected |
Definition at line 506 of file bitstring.py.
| str basestring = str |
Definition at line 457 of file bitstring.py.
| dict BIT_COUNT = dict(zip(xrange(256), [bin(i).count('1') for i in xrange(256)])) |
Definition at line 684 of file bitstring.py.
Definition at line 4247 of file bitstring.py.
| re BRACKET_RE = re.compile(r'(?P<factor>\d+)\*\(') |
Definition at line 645 of file bitstring.py.
| dict BYTE_REVERSAL_DICT = dict() |
Definition at line 444 of file bitstring.py.
| bool bytealigned = False |
Definition at line 81 of file bitstring.py.
| sys byteorder = sys.byteorder |
Definition at line 79 of file bitstring.py.
| int CACHE_SIZE = 1000 |
Definition at line 88 of file bitstring.py.
Definition at line 4246 of file bitstring.py.
| re DEFAULT_UINT = re.compile(r'(?P<len>[^=]+)?(=(?P<value>.*))?$', re.IGNORECASE) |
Definition at line 475 of file bitstring.py.
| tuple INIT_NAMES |
Definition at line 469 of file bitstring.py.
| dict init_with_length_and_offset |
Definition at line 2920 of file bitstring.py.
| dict init_with_length_only |
Definition at line 2924 of file bitstring.py.
| dict init_without_length_or_offset |
Definition at line 2938 of file bitstring.py.
| len LEADING_OCT_CHARS = len(oct(1)) - 1 |
Definition at line 460 of file bitstring.py.
| re LITERAL_RE = re.compile(r'(?P<name>0(x|o|b))(?P<value>.+)', re.IGNORECASE) |
Definition at line 480 of file bitstring.py.
| int MAX_CHARS = 250 |
Definition at line 85 of file bitstring.py.
| re MULTIPLICATIVE_RE = re.compile(r'(?P<factor>.*)\*(?P<token>.+)') |
Definition at line 477 of file bitstring.py.
| dict name_to_read |
Definition at line 2895 of file bitstring.py.
| list OCT_TO_BITS = ['{0:03b}'.format(i) for i in xrange(8)] |
Definition at line 681 of file bitstring.py.
| dict PACK_CODE_SIZE |
Definition at line 503 of file bitstring.py.
| dict REPLACEMENTS_BE |
Definition at line 490 of file bitstring.py.
| dict REPLACEMENTS_LE |
Definition at line 496 of file bitstring.py.
| re STRUCT_PACK_RE = re.compile(r'(?P<endian><|>|@)?(?P<fmt>(?:\d*[bBhHlLqQfd])+)$') |
Definition at line 483 of file bitstring.py.
| re STRUCT_SPLIT_RE = re.compile(r'\d*[bBhHlLqQfd]') |
Definition at line 486 of file bitstring.py.
| re TOKEN_RE |
Definition at line 473 of file bitstring.py.
| try : |
Definition at line 448 of file bitstring.py.
| range xrange = range |
Definition at line 456 of file bitstring.py.