Belle II Software
release-08-01-10
|
Public Member Functions | |
def | __init__ (self, auto=None, length=None, offset=None, **kwargs) |
def | __new__ (cls, auto=None, length=None, offset=None, **kwargs) |
def | __copy__ (self) |
def | __add__ (self, bs) |
def | read (self, fmt) |
def | readlist (self, fmt, **kwargs) |
def | readto (self, bs, bytealigned=None) |
def | peek (self, fmt) |
def | peeklist (self, fmt, **kwargs) |
def | bytealign (self) |
def | __new__ (cls, auto=None, length=None, offset=None, _cache=None, **kwargs) |
def | __lt__ (self, other) |
def | __gt__ (self, other) |
def | __le__ (self, other) |
def | __ge__ (self, other) |
def | __radd__ (self, bs) |
def | __getitem__ (self, key) |
def | __len__ (self) |
def | __str__ (self) |
def | __repr__ (self) |
def | __eq__ (self, bs) |
def | __ne__ (self, bs) |
def | __invert__ (self) |
def | __lshift__ (self, n) |
def | __rshift__ (self, n) |
def | __mul__ (self, n) |
def | __rmul__ (self, n) |
def | __and__ (self, bs) |
def | __rand__ (self, bs) |
def | __or__ (self, bs) |
def | __ror__ (self, bs) |
def | __xor__ (self, bs) |
def | __rxor__ (self, bs) |
def | __contains__ (self, bs) |
def | __hash__ (self) |
def | __nonzero__ (self) |
def | unpack (self, fmt, **kwargs) |
def | find (self, bs, start=None, end=None, bytealigned=None) |
def | findall (self, bs, start=None, end=None, count=None, bytealigned=None) |
def | rfind (self, bs, start=None, end=None, bytealigned=None) |
def | cut (self, bits, start=None, end=None, count=None) |
def | split (self, delimiter, start=None, end=None, count=None, bytealigned=None) |
def | join (self, sequence) |
def | tobytes (self) |
def | tofile (self, f) |
def | startswith (self, prefix, start=None, end=None) |
def | endswith (self, suffix, start=None, end=None) |
def | all (self, value, pos=None) |
def | any (self, value, pos=None) |
def | count (self, value) |
Properties | |
pos | |
bitpos | |
bytepos | |
_offset = property(_getoffset) | |
len | |
length | |
bool | |
hex | |
bin | |
oct | |
bytes | |
int | |
uint | |
float | |
intbe | |
uintbe | |
floatbe | |
intle | |
uintle | |
floatle | |
intne | |
uintne | |
floatne | |
ue | |
se | |
uie | |
sie | |
Private Member Functions | |
def | _setbytepos (self, bytepos) |
def | _getbytepos (self) |
def | _setbitpos (self, pos) |
def | _getbitpos (self) |
def | _clear (self) |
def | _initialise (self, auto, length, offset, **kwargs) |
def | _initialise_from_auto (self, auto, length, offset) |
def | _assertsanity (self) |
def | _init_with_token (cls, name, token_length, value) |
def | _setauto (self, s, length, offset) |
def | _setfile (self, filename, length, offset) |
def | _setbytes_safe (self, data, length=None, offset=0) |
def | _setbytes_unsafe (self, data, length, offset) |
def | _readbytes (self, length, start) |
def | _getbytes (self) |
def | _setuint (self, uint, length=None) |
def | _readuint (self, length, start) |
def | _getuint (self) |
def | _setint (self, int_, length=None) |
def | _readint (self, length, start) |
def | _getint (self) |
def | _setuintbe (self, uintbe, length=None) |
def | _readuintbe (self, length, start) |
def | _getuintbe (self) |
def | _setintbe (self, intbe, length=None) |
def | _readintbe (self, length, start) |
def | _getintbe (self) |
def | _setuintle (self, uintle, length=None) |
def | _readuintle (self, length, start) |
def | _getuintle (self) |
def | _setintle (self, intle, length=None) |
def | _readintle (self, length, start) |
def | _getintle (self) |
def | _setfloat (self, f, length=None) |
def | _readfloat (self, length, start) |
def | _getfloat (self) |
def | _setfloatle (self, f, length=None) |
def | _readfloatle (self, length, start) |
def | _getfloatle (self) |
def | _setue (self, i) |
def | _readue (self, pos) |
def | _getue (self) |
def | _setse (self, i) |
def | _getse (self) |
def | _readse (self, pos) |
def | _setuie (self, i) |
def | _readuie (self, pos) |
def | _getuie (self) |
def | _setsie (self, i) |
def | _getsie (self) |
def | _readsie (self, pos) |
def | _setbool (self, value) |
def | _getbool (self) |
def | _readbool (self, pos) |
def | _setbin_safe (self, binstring) |
def | _setbin_unsafe (self, binstring) |
def | _readbin (self, length, start) |
def | _getbin (self) |
def | _setoct (self, octstring) |
def | _readoct (self, length, start) |
def | _getoct (self) |
def | _sethex (self, hexstring) |
def | _readhex (self, length, start) |
def | _gethex (self) |
def | _getoffset (self) |
def | _getlength (self) |
def | _ensureinmemory (self) |
def | _converttobitstring (cls, bs, offset=0, cache=None) |
def | _copy (self) |
def | _slice (self, start, end) |
def | _readtoken (self, name, pos, length) |
def | _append (self, bs) |
def | _prepend (self, bs) |
def | _reverse (self) |
def | _truncatestart (self, bits) |
def | _truncateend (self, bits) |
def | _insert (self, bs, pos) |
def | _overwrite (self, bs, pos) |
def | _delete (self, bits, pos) |
def | _reversebytes (self, start, end) |
def | _set (self, pos) |
def | _unset (self, pos) |
def | _invert (self, pos) |
def | _invert_all (self) |
def | _ilshift (self, n) |
def | _irshift (self, n) |
def | _imul (self, n) |
def | _inplace_logical_helper (self, bs, f) |
def | _ior (self, bs) |
def | _iand (self, bs) |
def | _ixor (self, bs) |
def | _readbits (self, length, start) |
def | _validate_slice (self, start, end) |
def | _readlist (self, fmt, pos, **kwargs) |
def | _findbytes (self, bytes_, start, end, bytealigned) |
def | _findregex (self, reg_ex, start, end, bytealigned) |
Private Attributes | |
_pos | |
_datastore | |
Static Private Attributes | |
tuple | __slots__ = ('_pos') |
def | __bool__ = __nonzero__ |
def | _setfloatne = _setfloatle |
def | _readfloatne = _readfloatle |
def | _getfloatne = _getfloatle |
def | _setuintne = _setuintle |
def | _readuintne = _readuintle |
def | _getuintne = _getuintle |
def | _setintne = _setintle |
def | _readintne = _readintle |
def | _getintne = _getintle |
A container or stream holding an immutable sequence of bits. For a mutable container use the BitStream class instead. Methods inherited from Bits: all() -- Check if all specified bits are set to 1 or 0. any() -- Check if any of specified bits are set to 1 or 0. count() -- Count the number of bits set to 1 or 0. cut() -- Create generator of constant sized chunks. endswith() -- Return whether the bitstring ends with a sub-string. find() -- Find a sub-bitstring in the current bitstring. findall() -- Find all occurrences of a sub-bitstring in the current bitstring. join() -- Join bitstrings together using current bitstring. rfind() -- Seek backwards to find a sub-bitstring. split() -- Create generator of chunks split by a delimiter. startswith() -- Return whether the bitstring starts with a sub-bitstring. tobytes() -- Return bitstring as bytes, padding if needed. tofile() -- Write bitstring to file, padding if needed. unpack() -- Interpret bits using format string. Other methods: bytealign() -- Align to next byte boundary. peek() -- Peek at and interpret next bits as a single item. peeklist() -- Peek at and interpret next bits as a list of items. read() -- Read and interpret next bits as a single item. readlist() -- Read and interpret next bits as a list of items. Special methods: Also available are the operators [], ==, !=, +, *, ~, <<, >>, &, |, ^. Properties: bin -- The bitstring as a binary string. bool -- For single bit bitstrings, interpret as True or False. bytepos -- The current byte position in the bitstring. bytes -- The bitstring as a bytes object. float -- Interpret as a floating point number. floatbe -- Interpret as a big-endian floating point number. floatle -- Interpret as a little-endian floating point number. floatne -- Interpret as a native-endian floating point number. hex -- The bitstring as a hexadecimal string. int -- Interpret as a two's complement signed integer. intbe -- Interpret as a big-endian signed integer. intle -- Interpret as a little-endian signed integer. intne -- Interpret as a native-endian signed integer. len -- Length of the bitstring in bits. oct -- The bitstring as an octal string. pos -- The current bit position in the bitstring. se -- Interpret as a signed exponential-Golomb code. ue -- Interpret as an unsigned exponential-Golomb code. sie -- Interpret as a signed interleaved exponential-Golomb code. uie -- Interpret as an unsigned interleaved exponential-Golomb code. uint -- Interpret as a two's complement unsigned integer. uintbe -- Interpret as a big-endian unsigned integer. uintle -- Interpret as a little-endian unsigned integer. uintne -- Interpret as a native-endian unsigned integer.
Definition at line 3699 of file bitstring.py.
def __init__ | ( | self, | |
auto = None , |
|||
length = None , |
|||
offset = None , |
|||
** | kwargs | ||
) |
Either specify an 'auto' initialiser: auto -- a string of comma separated tokens, an integer, a file object, a bytearray, a boolean iterable or another bitstring. Or initialise via **kwargs with one (and only one) of: bytes -- raw data as a string, for example read from a binary file. bin -- binary string representation, e.g. '0b001010'. hex -- hexadecimal string representation, e.g. '0x2ef' oct -- octal string representation, e.g. '0o777'. uint -- an unsigned integer. int -- a signed integer. float -- a floating point number. uintbe -- an unsigned big-endian whole byte integer. intbe -- a signed big-endian whole byte integer. floatbe - a big-endian floating point number. uintle -- an unsigned little-endian whole byte integer. intle -- a signed little-endian whole byte integer. floatle -- a little-endian floating point number. uintne -- an unsigned native-endian whole byte integer. intne -- a signed native-endian whole byte integer. floatne -- a native-endian floating point number. se -- a signed exponential-Golomb code. ue -- an unsigned exponential-Golomb code. sie -- a signed interleaved exponential-Golomb code. uie -- an unsigned interleaved exponential-Golomb code. bool -- a boolean (True or False). filename -- a file which will be opened in binary read-only mode. Other keyword arguments: length -- length of the bitstring in bits, if needed and appropriate. It must be supplied for all integer and float initialisers. offset -- bit offset to the data. These offset bits are ignored and this is intended for use when initialising using 'bytes' or 'filename'.
Reimplemented from Bits.
Reimplemented in BitStream.
Definition at line 3764 of file bitstring.py.
def __add__ | ( | self, | |
bs | |||
) |
Concatenate bitstrings and return new bitstring. bs -- the bitstring to append.
Reimplemented from Bits.
Definition at line 3844 of file bitstring.py.
|
inherited |
Bit-wise 'and' between two bitstrings. Returns new bitstring. bs -- The bitstring to '&' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1079 of file bitstring.py.
|
inherited |
Return whether bs is contained in the current bitstring. bs -- The bitstring to search for.
Definition at line 1157 of file bitstring.py.
def __copy__ | ( | self | ) |
Return a new copy of the ConstBitStream for the copy module.
Reimplemented from Bits.
Reimplemented in BitStream.
Definition at line 3834 of file bitstring.py.
|
inherited |
Return True if two bitstrings have the same binary representation. >>> BitArray('0b1110') == '0xe' True
Definition at line 990 of file bitstring.py.
|
inherited |
Return a new bitstring representing a slice of the current bitstring. Indices are in units of the step parameter (default 1 bit). Stepping is used to specify the number of bits in each item. >>> print BitArray('0b00110')[1:4] '0b011' >>> print BitArray('0x00112233')[1:3:8] '0x1122'
Definition at line 893 of file bitstring.py.
|
inherited |
Return an integer hash of the object.
Definition at line 1175 of file bitstring.py.
|
inherited |
Return bitstring with every bit inverted. Raises Error if the bitstring is empty.
Definition at line 1012 of file bitstring.py.
|
inherited |
Return the length of the bitstring in bits.
Definition at line 938 of file bitstring.py.
|
inherited |
Return bitstring with bits shifted by n to the left. n -- the number of bits to shift. Must be >= 0.
Definition at line 1024 of file bitstring.py.
|
inherited |
Return bitstring consisting of n concatenations of self. Called for expression of the form 'a = b*3'. n -- The number of concatenations. Must be >= 0.
Definition at line 1055 of file bitstring.py.
|
inherited |
Return False if two bitstrings have the same binary representation. >>> BitArray('0b111') == '0x7' False
Definition at line 1003 of file bitstring.py.
|
inherited |
Return True if any bits are set to 1, otherwise return False.
Definition at line 1199 of file bitstring.py.
|
inherited |
Bit-wise 'or' between two bitstrings. Returns new bitstring. bs -- The bitstring to '|' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1105 of file bitstring.py.
|
inherited |
Append current bitstring to bs and return new bitstring. bs -- the string for the 'auto' initialiser that will be appended to.
Definition at line 884 of file bitstring.py.
|
inherited |
Bit-wise 'and' between two bitstrings. Returns new bitstring. bs -- the bitstring to '&' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1095 of file bitstring.py.
|
inherited |
Return representation that could be used to recreate the bitstring. If the returned string is too long it will be truncated. See __str__().
Definition at line 969 of file bitstring.py.
|
inherited |
Return bitstring consisting of n concatenations of self. Called for expressions of the form 'a = 3*b'. n -- The number of concatenations. Must be >= 0.
Definition at line 1070 of file bitstring.py.
|
inherited |
Bit-wise 'or' between two bitstrings. Returns new bitstring. bs -- The bitstring to '|' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1121 of file bitstring.py.
|
inherited |
Return bitstring with bits shifted by n to the right. n -- the number of bits to shift. Must be >= 0.
Definition at line 1039 of file bitstring.py.
|
inherited |
Bit-wise 'xor' between two bitstrings. Returns new bitstring. bs -- The bitstring to '^' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1147 of file bitstring.py.
|
inherited |
Return approximate string representation of bitstring for printing. Short strings will be given wholly in hexadecimal or binary. Longer strings may be part hexadecimal and part binary. Very long strings will be truncated with '...'.
Definition at line 942 of file bitstring.py.
|
inherited |
Bit-wise 'xor' between two bitstrings. Returns new bitstring. bs -- The bitstring to '^' with. Raises ValueError if the two bitstrings have differing lengths.
Definition at line 1131 of file bitstring.py.
|
privateinherited |
Append a bitstring to the current bitstring.
Definition at line 2035 of file bitstring.py.
|
privateinherited |
Check internal self consistency as a debugging aid.
Definition at line 1206 of file bitstring.py.
|
private |
Reset the bitstring to an empty state.
Reimplemented from Bits.
Definition at line 3830 of file bitstring.py.
|
privateinherited |
Convert bs to a bitstring and return it. offset gives the suggested bit offset of first significant bit, to optimise append etc.
Definition at line 1966 of file bitstring.py.
|
privateinherited |
Create and return a new copy of the Bits (always in memory).
Definition at line 2001 of file bitstring.py.
|
privateinherited |
Delete bits at pos.
Definition at line 2135 of file bitstring.py.
|
privateinherited |
Ensure the data is held in memory, not in a file.
Definition at line 1960 of file bitstring.py.
|
privateinherited |
Quicker version of find when everything's whole byte and byte aligned.
Definition at line 2365 of file bitstring.py.
|
privateinherited |
Find first occurrence of a compiled regular expression. Note that this doesn't support arbitrary regexes, in particular they must match a known length.
Definition at line 2392 of file bitstring.py.
|
privateinherited |
Return interpretation as a binary string.
Definition at line 1872 of file bitstring.py.
|
private |
Return the current position in the stream in bits.
Definition at line 3826 of file bitstring.py.
|
private |
Return the current position in the stream in bytes. Must be byte aligned.
Definition at line 3812 of file bitstring.py.
|
privateinherited |
Return the data as an ordinary string.
Definition at line 1355 of file bitstring.py.
|
privateinherited |
Interpret the whole bitstring as a float.
Definition at line 1586 of file bitstring.py.
|
privateinherited |
Interpret the whole bitstring as a little-endian float.
Definition at line 1625 of file bitstring.py.
|
privateinherited |
Return the hexadecimal representation as a string prefixed with '0x'. Raises an InterpretError if the bitstring's length is not a multiple of 4.
Definition at line 1945 of file bitstring.py.
|
privateinherited |
Return data as a two's complement signed int.
Definition at line 1454 of file bitstring.py.
|
privateinherited |
Return data as a big-endian two's complement signed int.
Definition at line 1490 of file bitstring.py.
|
privateinherited |
Return the length of the bitstring in bits.
Definition at line 1956 of file bitstring.py.
|
privateinherited |
Return interpretation as an octal string.
Definition at line 1906 of file bitstring.py.
|
privateinherited |
Return data as signed exponential-Golomb code. Raises InterpretError if bitstring is not a single exponential-Golomb code.
Definition at line 1698 of file bitstring.py.
|
privateinherited |
Return data as signed interleaved exponential-Golomb code. Raises InterpretError if bitstring is not a single exponential-Golomb code.
Definition at line 1781 of file bitstring.py.
|
privateinherited |
Return data as unsigned exponential-Golomb code. Raises InterpretError if bitstring is not a single exponential-Golomb code.
Definition at line 1676 of file bitstring.py.
|
privateinherited |
Return data as unsigned interleaved exponential-Golomb code. Raises InterpretError if bitstring is not a single exponential-Golomb code.
Definition at line 1759 of file bitstring.py.
|
privateinherited |
Return data as an unsigned int.
Definition at line 1417 of file bitstring.py.
|
privateinherited |
Return data as a big-endian two's complement unsigned int.
Definition at line 1472 of file bitstring.py.
|
privateinherited |
Shift bits by n to the left in place. Return self.
Definition at line 2196 of file bitstring.py.
|
privateinherited |
Concatenate n copies of self in place. Return self.
Definition at line 2210 of file bitstring.py.
|
privateinherited |
Helper function containing most of the __ior__, __iand__, __ixor__ code.
Definition at line 2224 of file bitstring.py.
|
privateinherited |
Insert bs at pos.
Definition at line 2081 of file bitstring.py.
|
privateinherited |
Flip bit at pos 1<->0.
Definition at line 2184 of file bitstring.py.
|
privateinherited |
Invert every bit.
Definition at line 2189 of file bitstring.py.
|
privateinherited |
Shift bits by n to the right in place. Return self.
Definition at line 2203 of file bitstring.py.
|
privateinherited |
Overwrite with bs at pos.
Definition at line 2102 of file bitstring.py.
|
privateinherited |
Prepend a bitstring to the current bitstring.
Definition at line 2039 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a binary string.
Definition at line 1855 of file bitstring.py.
|
privateinherited |
Read some bits from the bitstring and return newly constructed bitstring.
Definition at line 2249 of file bitstring.py.
|
privateinherited |
Read bytes and return them. Note that length is in bits.
Definition at line 1346 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a float.
Definition at line 1568 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian float.
Definition at line 1606 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a hex string.
Definition at line 1928 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a signed int
Definition at line 1444 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a big-endian signed int.
Definition at line 1483 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian signed int.
Definition at line 1539 of file bitstring.py.
|
privateinherited |
Read bits and interpret as an octal string.
Definition at line 1891 of file bitstring.py.
|
privateinherited |
Return interpretation of next bits as a signed exponential-Golomb code. Advances position to after the read code. Raises ReadError if the end of the bitstring is encountered while reading the code.
Definition at line 1712 of file bitstring.py.
|
privateinherited |
Return interpretation of next bits as a signed interleaved exponential-Golomb code. Advances position to after the read code. Raises ReadError if the end of the bitstring is encountered while reading the code.
Definition at line 1795 of file bitstring.py.
|
privateinherited |
Reads a token from the bitstring and returns the result.
Definition at line 2019 of file bitstring.py.
|
privateinherited |
Return interpretation of next bits as unsigned exponential-Golomb code. Raises ReadError if the end of the bitstring is encountered while reading the code.
Definition at line 1651 of file bitstring.py.
|
privateinherited |
Return interpretation of next bits as unsigned interleaved exponential-Golomb code. Raises ReadError if the end of the bitstring is encountered while reading the code.
Definition at line 1739 of file bitstring.py.
|
privateinherited |
Read bits and interpret as an unsigned int.
Definition at line 1399 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a big-endian unsigned int.
Definition at line 1465 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian unsigned int.
Definition at line 1501 of file bitstring.py.
|
privateinherited |
Reverse all bits in-place.
Definition at line 2043 of file bitstring.py.
|
privateinherited |
Reverse bytes in-place.
Definition at line 2161 of file bitstring.py.
|
privateinherited |
Set bit at pos to 1.
Definition at line 2174 of file bitstring.py.
|
privateinherited |
Set bitstring from a bitstring, file, bool, integer, array, iterable or string.
Definition at line 1256 of file bitstring.py.
|
privateinherited |
Reset the bitstring to the value given in binstring.
Definition at line 1834 of file bitstring.py.
|
privateinherited |
Same as _setbin_safe, but input isn't sanity checked. binstring mustn't start with '0b'.
Definition at line 1841 of file bitstring.py.
|
private |
Move to absolute postion bit in bitstream.
Definition at line 3818 of file bitstring.py.
|
private |
Move to absolute byte-aligned position in stream.
Definition at line 3808 of file bitstring.py.
|
privateinherited |
Set the data from a string.
Definition at line 1325 of file bitstring.py.
|
privateinherited |
Unchecked version of _setbytes_safe.
Definition at line 1341 of file bitstring.py.
|
privateinherited |
Use file as source of bits.
Definition at line 1310 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have the value given in hexstring.
Definition at line 1910 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have given signed int interpretation.
Definition at line 1421 of file bitstring.py.
|
privateinherited |
Set bitstring to a big-endian signed int interpretation.
Definition at line 1476 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have the value given in octstring.
Definition at line 1876 of file bitstring.py.
|
privateinherited |
Initialise bitstring with signed exponential-Golomb code for integer i.
Definition at line 1690 of file bitstring.py.
|
privateinherited |
Initialise bitstring with signed interleaved exponential-Golomb code for integer i.
Definition at line 1773 of file bitstring.py.
|
privateinherited |
Initialise bitstring with unsigned exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1629 of file bitstring.py.
|
privateinherited |
Initialise bitstring with unsigned interleaved exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1728 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have given unsigned int interpretation.
Definition at line 1362 of file bitstring.py.
|
privateinherited |
Set the bitstring to a big-endian unsigned int interpretation.
Definition at line 1458 of file bitstring.py.
|
privateinherited |
Used internally to get a slice, without error checking.
Definition at line 2008 of file bitstring.py.
|
privateinherited |
Truncate bits from the end of the bitstring.
Definition at line 2068 of file bitstring.py.
|
privateinherited |
Truncate bits from the start of the bitstring.
Definition at line 2055 of file bitstring.py.
|
privateinherited |
Set bit at pos to 0.
Definition at line 2179 of file bitstring.py.
|
privateinherited |
Validate start and end and return them as positive bit positions.
Definition at line 2253 of file bitstring.py.
|
inherited |
Return True if one or many bits are all set to value. value -- If value is True then checks for bits set to 1, otherwise checks for bits set to 0. pos -- An iterable of bit positions. Negative numbers are treated in the same way as slice indices. Defaults to the whole bitstring.
Definition at line 2732 of file bitstring.py.
|
inherited |
Return True if any of one or many bits are set to value. value -- If value is True then checks for bits set to 1, otherwise checks for bits set to 0. pos -- An iterable of bit positions. Negative numbers are treated in the same way as slice indices. Defaults to the whole bitstring.
Definition at line 2754 of file bitstring.py.
def bytealign | ( | self | ) |
Align to next byte and return number of skipped bits. Raises ValueError if the end of the bitstring is reached before aligning to the next byte.
Definition at line 3997 of file bitstring.py.
|
inherited |
Return count of total number of either zero or one bits. value -- If True then bits set to 1 are counted, otherwise bits set to 0 are counted. >>> Bits('0xef').count(1) 7
Definition at line 2776 of file bitstring.py.
|
inherited |
Return bitstring generator by cutting into bits sized chunks. bits -- The size in bits of the bitstring chunks to generate. start -- The bit position to start the first cut. Defaults to 0. end -- The bit position one past the last bit to use in the cut. Defaults to self.len. count -- If specified then at most count items are generated. Default is to cut as many times as possible.
Definition at line 2553 of file bitstring.py.
|
inherited |
Return whether the current bitstring ends with suffix. suffix -- The bitstring to search for. start -- The bit position to start from. Defaults to 0. end -- The bit position to end at. Defaults to self.len.
Definition at line 2717 of file bitstring.py.
|
inherited |
Find first occurrence of substring bs. Returns a single item tuple with the bit position if found, or an empty tuple if not found. The bit position (pos property) will also be set to the start of the substring if it is found. bs -- The bitstring to find. start -- The bit position to start the search. Defaults to 0. end -- The bit position one past the last bit to search. Defaults to self.len. bytealigned -- If True the bitstring will only be found on byte boundaries. Raises ValueError if bs is empty, if start < 0, if end > self.len or if end < start. >>> BitArray('0xc3e').find('0b1111') (6,)
Definition at line 2424 of file bitstring.py.
|
inherited |
Find all occurrences of bs. Return generator of bit positions. bs -- The bitstring to find. start -- The bit position to start the search. Defaults to 0. end -- The bit position one past the last bit to search. Defaults to self.len. count -- The maximum number of occurrences to find. bytealigned -- If True the bitstring will only be found on byte boundaries. Raises ValueError if bs is empty, if start < 0, if end > self.len or if end < start. Note that all occurrences of bs are found, even if they overlap.
Definition at line 2462 of file bitstring.py.
|
inherited |
Return concatenation of bitstrings joined by self. sequence -- A sequence of bitstrings.
Definition at line 2637 of file bitstring.py.
def peek | ( | self, | |
fmt | |||
) |
Interpret next bits according to format string and return result. fmt -- Token string describing how to interpret the next bits. The position in the bitstring is not changed. If not enough bits are available then all bits to the end of the bitstring will be used. Raises ReadError if not enough bits are available. Raises ValueError if the format is not understood. See the docstring for 'read' for token examples.
Definition at line 3956 of file bitstring.py.
def peeklist | ( | self, | |
fmt, | |||
** | kwargs | ||
) |
Interpret next bits according to format string(s) and return list. fmt -- One or more strings with comma separated tokens describing how to interpret the next bits in the bitstring. kwargs -- A dictionary or keyword-value pairs - the keywords used in the format string will be replaced with their given value. The position in the bitstring is not changed. If not enough bits are available then all bits to the end of the bitstring will be used. Raises ReadError if not enough bits are available. Raises ValueError if the format is not understood. See the docstring for 'read' for token examples.
Definition at line 3975 of file bitstring.py.
def read | ( | self, | |
fmt | |||
) |
Interpret next bits according to the format string and return result. fmt -- Token string describing how to interpret the next bits. 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' : next bits as unsigned exp-Golomb code 'se' : next bits as signed exp-Golomb code 'uie' : next bits as unsigned interleaved exp-Golomb code 'sie' : next bits as signed interleaved exp-Golomb code 'bits:5' : 5 bits as a bitstring 'bytes:10' : 10 bytes as a bytes object 'bool' : 1 bit as a bool 'pad:3' : 3 bits of padding to ignore - returns None fmt may also be an integer, which will be treated like the 'bits' token. The position in the bitstring is advanced to after the read items. Raises ReadError if not enough bits are available. Raises ValueError if the format is not understood.
Definition at line 3854 of file bitstring.py.
def readlist | ( | self, | |
fmt, | |||
** | kwargs | ||
) |
Interpret next bits according to format string(s) and return list. fmt -- A single string or list of strings with comma separated tokens describing how to interpret the next bits in the bitstring. Items can also be integers, for reading new bitstring of the given length. kwargs -- A dictionary or keyword-value pairs - the keywords used in the format string will be replaced with their given value. The position in the bitstring is advanced to after the read items. Raises ReadError is not enough bits are available. Raises ValueError if the format is not understood. See the docstring for 'read' for token examples. 'pad' tokens are skipped and not added to the returned list. >>> h, b1, b2 = s.readlist('hex:20, bin:5, bin:3') >>> i, bs1, bs2 = s.readlist(['uint:12', 10, 10])
Definition at line 3911 of file bitstring.py.
def readto | ( | self, | |
bs, | |||
bytealigned = None |
|||
) |
Read up to and including next occurrence of bs and return result. bs -- The bitstring to find. An integer is not permitted. bytealigned -- If True the bitstring will only be found on byte boundaries. Raises ValueError if bs is empty. Raises ReadError if bs is not found.
Definition at line 3935 of file bitstring.py.
|
inherited |
Find final occurrence of substring bs. Returns a single item tuple with the bit position if found, or an empty tuple if not found. The bit position (pos property) will also be set to the start of the substring if it is found. bs -- The bitstring to find. start -- The bit position to end the reverse search. Defaults to 0. end -- The bit position one past the first bit to reverse search. Defaults to self.len. bytealigned -- If True the bitstring will only be found on byte boundaries. Raises ValueError if bs is empty, if start < 0, if end > self.len or if end < start.
Definition at line 2514 of file bitstring.py.
|
inherited |
Return bitstring generator by splittling using a delimiter. The first item returned is the initial bitstring before the delimiter, which may be an empty bitstring. delimiter -- The bitstring used as the divider. start -- The bit position to start the split. Defaults to 0. end -- The bit position one past the last bit to use in the split. Defaults to self.len. count -- If specified then at most count items are generated. Default is to split as many times as possible. bytealigned -- If True splits will only occur on byte boundaries. Raises ValueError if the delimiter is empty.
Definition at line 2580 of file bitstring.py.
|
inherited |
Return whether the current bitstring starts with prefix. prefix -- The bitstring to search for. start -- The bit position to start from. Defaults to 0. end -- The bit position to end at. Defaults to self.len.
Definition at line 2702 of file bitstring.py.
|
inherited |
Return the bitstring as bytes, padding with zero bits if needed. Up to seven zero bits will be added at the end to byte align.
Definition at line 2655 of file bitstring.py.
|
inherited |
Write the bitstring to a file object, padding with zero bits if needed. Up to seven zero bits will be added at the end to byte align.
Definition at line 2668 of file bitstring.py.
|
inherited |
Interpret the whole bitstring using fmt and return list. fmt -- A single string or a list of strings with comma separated tokens describing how to interpret the bits in the bitstring. Items can also be integers, for reading new bitstring of the given length. kwargs -- A dictionary or keyword-value pairs - the keywords used in the format string will be replaced with their given value. Raises ValueError if the format is not understood. If not enough bits are available then all bits to the end of the bitstring will be used. See the docstring for 'read' for token examples.
Definition at line 2271 of file bitstring.py.
|
staticinherited |
Definition at line 2835 of file bitstring.py.
|
static |
Definition at line 4012 of file bitstring.py.
|
staticinherited |
Definition at line 2829 of file bitstring.py.
|
static |
Definition at line 4015 of file bitstring.py.
|
staticinherited |
Definition at line 2841 of file bitstring.py.
|
staticinherited |
Definition at line 2850 of file bitstring.py.
|
staticinherited |
Definition at line 2859 of file bitstring.py.
|
staticinherited |
Definition at line 2868 of file bitstring.py.
|
staticinherited |
Definition at line 2877 of file bitstring.py.
|
staticinherited |
Definition at line 2832 of file bitstring.py.
|
staticinherited |
Definition at line 2844 of file bitstring.py.
|
staticinherited |
Definition at line 2853 of file bitstring.py.
|
staticinherited |
Definition at line 2862 of file bitstring.py.
|
staticinherited |
Definition at line 2871 of file bitstring.py.
|
staticinherited |
Definition at line 2823 of file bitstring.py.
|
staticinherited |
Definition at line 2826 of file bitstring.py.
|
staticinherited |
Definition at line 2838 of file bitstring.py.
|
static |
Definition at line 4009 of file bitstring.py.
|
staticinherited |
Definition at line 2883 of file bitstring.py.
|
staticinherited |
Definition at line 2889 of file bitstring.py.
|
staticinherited |
Definition at line 2880 of file bitstring.py.
|
staticinherited |
Definition at line 2886 of file bitstring.py.
|
staticinherited |
Definition at line 2847 of file bitstring.py.
|
staticinherited |
Definition at line 2856 of file bitstring.py.
|
staticinherited |
Definition at line 2865 of file bitstring.py.
|
staticinherited |
Definition at line 2874 of file bitstring.py.