![]() |
Belle II Software
release-05-02-19
|
Public Member Functions | |
def | __init__ (self, auto=None, length=None, offset=None, **kwargs) |
def | __new__ (cls, auto=None, length=None, offset=None, **kwargs) |
def | __iadd__ (self, bs) |
def | __copy__ (self) |
def | __setitem__ (self, key, value) |
def | __delitem__ (self, key) |
def | __ilshift__ (self, n) |
def | __irshift__ (self, n) |
def | __imul__ (self, n) |
def | __ior__ (self, bs) |
def | __iand__ (self, bs) |
def | __ixor__ (self, bs) |
def | replace (self, old, new, start=None, end=None, count=None, bytealigned=None) |
def | insert (self, bs, pos=None) |
def | overwrite (self, bs, pos=None) |
def | append (self, bs) |
def | prepend (self, bs) |
def | reverse (self, start=None, end=None) |
def | set (self, value, pos=None) |
def | invert (self, pos=None) |
def | ror (self, bits, start=None, end=None) |
def | rol (self, bits, start=None, end=None) |
def | byteswap (self, fmt=None, start=None, end=None, repeat=True) |
def | clear (self) |
def | copy (self) |
def | __new__ (cls, auto=None, length=None, offset=None, _cache={}, **kwargs) |
def | __lt__ (self, other) |
def | __gt__ (self, other) |
def | __le__ (self, other) |
def | __ge__ (self, other) |
def | __add__ (self, bs) |
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 | |
int | |
uint | |
float | |
intbe | |
uintbe | |
floatbe | |
intle | |
uintle | |
floatle | |
intne | |
uintne | |
floatne | |
ue | |
se | |
uie | |
sie | |
hex | |
bin | |
oct | |
bool | |
bytes | |
_offset = property(_getoffset) | |
len | |
length | |
Private Member Functions | |
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 | _clear (self) |
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={}) |
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__ = () |
__hash__ = None | |
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 holding a mutable sequence of bits. Subclass of the immutable Bits class. Inherits all of its methods (except __hash__) and adds mutating methods. Mutating methods: append() -- Append a bitstring. byteswap() -- Change byte endianness in-place. insert() -- Insert a bitstring. invert() -- Flip bit(s) between one and zero. overwrite() -- Overwrite a section with a new bitstring. prepend() -- Prepend a bitstring. replace() -- Replace occurrences of one bitstring with another. reverse() -- Reverse bits in-place. rol() -- Rotate bits to the left. ror() -- Rotate bits to the right. set() -- Set bit(s) to 1 or 0. 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. Special methods: Mutating operators are available: [], <<=, >>=, +=, *=, &=, |= and ^= in addition to the inherited [], ==, !=, +, *, ~, <<, >>, &, | and ^. 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 2943 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 3019 of file bitstring.py.
|
inherited |
Concatenate bitstrings and return new bitstring. bs -- the bitstring to append.
Reimplemented in ConstBitStream.
Definition at line 864 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 1075 of file bitstring.py.
|
inherited |
Return whether bs is contained in the current bitstring. bs -- The bitstring to search for.
Definition at line 1153 of file bitstring.py.
def __copy__ | ( | self | ) |
Return a new copy of the BitArray.
Reimplemented from Bits.
Reimplemented in BitStream.
Definition at line 3075 of file bitstring.py.
def __delitem__ | ( | self, | |
key | |||
) |
Delete item or range. Indices are in units of the step parameter (default 1 bit). Stepping is used to specify the number of bits in each item. >>> a = BitArray('0x001122') >>> del a[1:2:8] >>> print a 0x0022
Definition at line 3194 of file bitstring.py.
|
inherited |
Return True if two bitstrings have the same binary representation. >>> BitArray('0b1110') == '0xe' True
Definition at line 986 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 889 of file bitstring.py.
|
inherited |
Return an integer hash of the object.
Definition at line 1171 of file bitstring.py.
def __iadd__ | ( | self, | |
bs | |||
) |
Append bs to current bitstring. Return self. bs -- the bitstring to append.
Definition at line 3066 of file bitstring.py.
def __ilshift__ | ( | self, | |
n | |||
) |
Shift bits by n to the left in place. Return self. n -- the number of bits to shift. Must be >= 0.
Definition at line 3243 of file bitstring.py.
def __imul__ | ( | self, | |
n | |||
) |
Concatenate n copies of self in place. Return self. Called for expressions of the form 'a *= 3'. n -- The number of concatenations. Must be >= 0.
Definition at line 3273 of file bitstring.py.
|
inherited |
Return bitstring with every bit inverted. Raises Error if the bitstring is empty.
Definition at line 1008 of file bitstring.py.
def __irshift__ | ( | self, | |
n | |||
) |
Shift bits by n to the right in place. Return self. n -- the number of bits to shift. Must be >= 0.
Definition at line 3258 of file bitstring.py.
|
inherited |
Return the length of the bitstring in bits.
Definition at line 934 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 1020 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 1051 of file bitstring.py.
|
inherited |
Return False if two bitstrings have the same binary representation. >>> BitArray('0b111') == '0x7' False
Definition at line 999 of file bitstring.py.
|
inherited |
Return True if any bits are set to 1, otherwise return False.
Definition at line 1195 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 1101 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 880 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 1091 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 965 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 1066 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 1117 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 1035 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 1143 of file bitstring.py.
def __setitem__ | ( | self, | |
key, | |||
value | |||
) |
Set item or range to new value. Indices are in units of the step parameter (default 1 bit). Stepping is used to specify the number of bits in each item. If the length of the bitstring is changed then pos will be moved to after the inserted section, otherwise it will remain unchanged. >>> s = BitArray('0xff') >>> s[0:1:4] = '0xe' >>> print s '0xef' >>> s[4:4] = '0x00' >>> print s '0xe00f'
Definition at line 3086 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 938 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 1127 of file bitstring.py.
|
privateinherited |
Append a bitstring to the current bitstring.
Definition at line 2029 of file bitstring.py.
|
privateinherited |
Check internal self consistency as a debugging aid.
Definition at line 1202 of file bitstring.py.
|
privateinherited |
Reset the bitstring to an empty state.
Reimplemented in ConstBitStream.
Definition at line 1248 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 1962 of file bitstring.py.
|
privateinherited |
Create and return a new copy of the Bits (always in memory).
Definition at line 1995 of file bitstring.py.
|
privateinherited |
Delete bits at pos.
Definition at line 2129 of file bitstring.py.
|
privateinherited |
Ensure the data is held in memory, not in a file.
Definition at line 1956 of file bitstring.py.
|
privateinherited |
Quicker version of find when everything's whole byte and byte aligned.
Definition at line 2359 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 2386 of file bitstring.py.
|
privateinherited |
Return interpretation as a binary string.
Definition at line 1868 of file bitstring.py.
|
privateinherited |
Return the data as an ordinary string.
Definition at line 1351 of file bitstring.py.
|
privateinherited |
Interpret the whole bitstring as a float.
Definition at line 1582 of file bitstring.py.
|
privateinherited |
Interpret the whole bitstring as a little-endian float.
Definition at line 1621 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 1941 of file bitstring.py.
|
privateinherited |
Return data as a two's complement signed int.
Definition at line 1450 of file bitstring.py.
|
privateinherited |
Return data as a big-endian two's complement signed int.
Definition at line 1486 of file bitstring.py.
|
privateinherited |
Return the length of the bitstring in bits.
Definition at line 1952 of file bitstring.py.
|
privateinherited |
Return interpretation as an octal string.
Definition at line 1902 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 1694 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 1777 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 1672 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 1755 of file bitstring.py.
|
privateinherited |
Return data as an unsigned int.
Definition at line 1413 of file bitstring.py.
|
privateinherited |
Return data as a big-endian two's complement unsigned int.
Definition at line 1468 of file bitstring.py.
|
privateinherited |
Shift bits by n to the left in place. Return self.
Definition at line 2190 of file bitstring.py.
|
privateinherited |
Concatenate n copies of self in place. Return self.
Definition at line 2204 of file bitstring.py.
|
privateinherited |
Helper function containing most of the __ior__, __iand__, __ixor__ code.
Definition at line 2218 of file bitstring.py.
|
privateinherited |
Insert bs at pos.
Definition at line 2075 of file bitstring.py.
|
privateinherited |
Flip bit at pos 1<->0.
Definition at line 2178 of file bitstring.py.
|
privateinherited |
Invert every bit.
Definition at line 2183 of file bitstring.py.
|
privateinherited |
Shift bits by n to the right in place. Return self.
Definition at line 2197 of file bitstring.py.
|
privateinherited |
Overwrite with bs at pos.
Definition at line 2096 of file bitstring.py.
|
privateinherited |
Prepend a bitstring to the current bitstring.
Definition at line 2033 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a binary string.
Definition at line 1851 of file bitstring.py.
|
privateinherited |
Read some bits from the bitstring and return newly constructed bitstring.
Definition at line 2243 of file bitstring.py.
|
privateinherited |
Read bytes and return them. Note that length is in bits.
Definition at line 1342 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a float.
Definition at line 1564 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian float.
Definition at line 1602 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a hex string.
Definition at line 1924 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a signed int
Definition at line 1440 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a big-endian signed int.
Definition at line 1479 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian signed int.
Definition at line 1535 of file bitstring.py.
|
privateinherited |
Read bits and interpret as an octal string.
Definition at line 1887 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 1708 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 1791 of file bitstring.py.
|
privateinherited |
Reads a token from the bitstring and returns the result.
Definition at line 2013 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 1647 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 1735 of file bitstring.py.
|
privateinherited |
Read bits and interpret as an unsigned int.
Definition at line 1395 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a big-endian unsigned int.
Definition at line 1461 of file bitstring.py.
|
privateinherited |
Read bits and interpret as a little-endian unsigned int.
Definition at line 1497 of file bitstring.py.
|
privateinherited |
Reverse all bits in-place.
Definition at line 2037 of file bitstring.py.
|
privateinherited |
Reverse bytes in-place.
Definition at line 2155 of file bitstring.py.
|
privateinherited |
Set bit at pos to 1.
Definition at line 2168 of file bitstring.py.
|
privateinherited |
Set bitstring from a bitstring, file, bool, integer, array, iterable or string.
Definition at line 1252 of file bitstring.py.
|
privateinherited |
Reset the bitstring to the value given in binstring.
Definition at line 1830 of file bitstring.py.
|
privateinherited |
Same as _setbin_safe, but input isn't sanity checked. binstring mustn't start with '0b'.
Definition at line 1837 of file bitstring.py.
|
privateinherited |
Set the data from a string.
Definition at line 1321 of file bitstring.py.
|
privateinherited |
Unchecked version of _setbytes_safe.
Definition at line 1337 of file bitstring.py.
|
privateinherited |
Use file as source of bits.
Definition at line 1306 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have the value given in hexstring.
Definition at line 1906 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have given signed int interpretation.
Definition at line 1417 of file bitstring.py.
|
privateinherited |
Set bitstring to a big-endian signed int interpretation.
Definition at line 1472 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have the value given in octstring.
Definition at line 1872 of file bitstring.py.
|
privateinherited |
Initialise bitstring with signed exponential-Golomb code for integer i.
Definition at line 1686 of file bitstring.py.
|
privateinherited |
Initialise bitstring with signed interleaved exponential-Golomb code for integer i.
Definition at line 1769 of file bitstring.py.
|
privateinherited |
Initialise bitstring with unsigned exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1625 of file bitstring.py.
|
privateinherited |
Initialise bitstring with unsigned interleaved exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1724 of file bitstring.py.
|
privateinherited |
Reset the bitstring to have given unsigned int interpretation.
Definition at line 1358 of file bitstring.py.
|
privateinherited |
Set the bitstring to a big-endian unsigned int interpretation.
Definition at line 1454 of file bitstring.py.
|
privateinherited |
Used internally to get a slice, without error checking.
Definition at line 2002 of file bitstring.py.
|
privateinherited |
Truncate bits from the end of the bitstring.
Definition at line 2062 of file bitstring.py.
|
privateinherited |
Truncate bits from the start of the bitstring.
Definition at line 2049 of file bitstring.py.
|
privateinherited |
Set bit at pos to 0.
Definition at line 2173 of file bitstring.py.
|
privateinherited |
Validate start and end and return them as positive bit positions.
Definition at line 2247 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 2726 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 2748 of file bitstring.py.
def append | ( | self, | |
bs | |||
) |
Append a bitstring to the current bitstring. bs -- The bitstring to append.
Definition at line 3424 of file bitstring.py.
def byteswap | ( | self, | |
fmt = None , |
|||
start = None , |
|||
end = None , |
|||
repeat = True |
|||
) |
Change the endianness in-place. Return number of repeats of fmt done. fmt -- A compact structure string, an integer number of bytes or an iterable of integers. Defaults to 0, which byte reverses the whole bitstring. start -- Start bit position, defaults to 0. end -- End bit position, defaults to self.len. repeat -- If True (the default) the byte swapping pattern is repeated as much as possible.
Definition at line 3560 of file bitstring.py.
def clear | ( | self | ) |
Remove all bits, reset to zero length.
Definition at line 3620 of file bitstring.py.
def copy | ( | self | ) |
Return a copy of the bitstring.
Definition at line 3624 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 2770 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 2547 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 2711 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 2418 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 2456 of file bitstring.py.
def insert | ( | self, | |
bs, | |||
pos = None |
|||
) |
Insert bs at bit position pos. bs -- The bitstring to insert. pos -- The bit position to insert at. Raises ValueError if pos < 0 or pos > self.len.
Definition at line 3372 of file bitstring.py.
def invert | ( | self, | |
pos = None |
|||
) |
Invert one or many bits from 0 to 1 or vice versa. pos -- Either a single bit position or an iterable of bit positions. Negative numbers are treated in the same way as slice indices. Raises IndexError if pos < -self.len or pos >= self.len.
Definition at line 3493 of file bitstring.py.
|
inherited |
Return concatenation of bitstrings joined by self. sequence -- A sequence of bitstrings.
Definition at line 2631 of file bitstring.py.
def overwrite | ( | self, | |
bs, | |||
pos = None |
|||
) |
Overwrite with bs at bit position pos. bs -- The bitstring to overwrite with. pos -- The bit position to begin overwriting from. Raises ValueError if pos < 0 or pos + bs.len > self.len
Definition at line 3397 of file bitstring.py.
def prepend | ( | self, | |
bs | |||
) |
Prepend a bitstring to the current bitstring. bs -- The bitstring to prepend.
Reimplemented in BitStream.
Definition at line 3434 of file bitstring.py.
def replace | ( | self, | |
old, | |||
new, | |||
start = None , |
|||
end = None , |
|||
count = None , |
|||
bytealigned = None |
|||
) |
Replace all occurrences of old with new in place. Returns number of replacements made. old -- The bitstring to replace. new -- The replacement bitstring. start -- Any occurrences that start before this will not be replaced. Defaults to 0. end -- Any occurrences that finish after this will not be replaced. Defaults to self.len. count -- The maximum number of replacements to make. Defaults to replace all occurrences. bytealigned -- If True replacements will only be made on byte boundaries. Raises ValueError if old is empty or if start or end are out of range.
Definition at line 3305 of file bitstring.py.
def reverse | ( | self, | |
start = None , |
|||
end = None |
|||
) |
Reverse bits in-place. start -- Position of first bit to reverse. Defaults to 0. end -- One past the position of the last bit to reverse. Defaults to self.len. Using on an empty bitstring will have no effect. Raises ValueError if start < 0, end > self.len or end < start.
Definition at line 3443 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 2508 of file bitstring.py.
def rol | ( | self, | |
bits, | |||
start = None , |
|||
end = None |
|||
) |
Rotate bits to the left in-place. bits -- The number of bits to rotate by. start -- Start of slice to rotate. Defaults to 0. end -- End of slice to rotate. Defaults to self.len. Raises ValueError if bits < 0.
Definition at line 3538 of file bitstring.py.
def ror | ( | self, | |
bits, | |||
start = None , |
|||
end = None |
|||
) |
Rotate bits to the right in-place. bits -- The number of bits to rotate by. start -- Start of slice to rotate. Defaults to 0. end -- End of slice to rotate. Defaults to self.len. Raises ValueError if bits < 0.
Definition at line 3516 of file bitstring.py.
def set | ( | self, | |
value, | |||
pos = None |
|||
) |
Set one or many bits to 1 or 0. value -- If True bits are set to 1, otherwise they are set to 0. pos -- Either a single bit position or an iterable of bit positions. Negative numbers are treated in the same way as slice indices. Defaults to the entire bitstring. Raises IndexError if pos < -self.len or pos >= self.len.
Definition at line 3463 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 2574 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 2696 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 2649 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 2662 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 2265 of file bitstring.py.
|
static |
Definition at line 3679 of file bitstring.py.
|
static |
Definition at line 3685 of file bitstring.py.
|
static |
Definition at line 3688 of file bitstring.py.
|
static |
Definition at line 3634 of file bitstring.py.
|
static |
Definition at line 3643 of file bitstring.py.
|
static |
Definition at line 3652 of file bitstring.py.
|
static |
Definition at line 3661 of file bitstring.py.
|
static |
Definition at line 3676 of file bitstring.py.
|
static |
Definition at line 3628 of file bitstring.py.
|
static |
Definition at line 3637 of file bitstring.py.
|
static |
Definition at line 3646 of file bitstring.py.
|
static |
Definition at line 3655 of file bitstring.py.
|
staticinherited |
Definition at line 2817 of file bitstring.py.
|
staticinherited |
Definition at line 2820 of file bitstring.py.
|
static |
Definition at line 3682 of file bitstring.py.
|
static |
Definition at line 3667 of file bitstring.py.
|
static |
Definition at line 3673 of file bitstring.py.
|
static |
Definition at line 3664 of file bitstring.py.
|
static |
Definition at line 3670 of file bitstring.py.
|
static |
Definition at line 3631 of file bitstring.py.
|
static |
Definition at line 3640 of file bitstring.py.
|
static |
Definition at line 3649 of file bitstring.py.
|
static |
Definition at line 3658 of file bitstring.py.