Belle II Software development
|
Public Member Functions | |
def | __init__ (self, auto=None, length=None, offset=None, **kwargs) |
def | __new__ (cls, auto=None, length=None, offset=None, _cache=None, **kwargs) |
def | __copy__ (self) |
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) |
Static Public Attributes | |
else : | |
Protected 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=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) |
Protected Attributes | |
_pos | |
_datastore | |
Static Protected Attributes | |
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 |
Properties | |
property | _offset = property(_getoffset) |
property | len |
property | length |
property | bool |
property | hex |
property | bin |
property | oct |
property | bytes |
property | int |
property | uint |
property | float |
property | intbe |
property | uintbe |
property | floatbe |
property | intle |
property | uintle |
property | floatle |
property | intne |
property | uintne |
property | floatne |
property | ue |
property | se |
property | uie |
property | sie |
Static Private Attributes | |
tuple | __slots__ = ('_datastore') |
def | __bool__ = __nonzero__ |
A container holding an immutable sequence of bits. For a mutable container use the BitArray class instead. Methods: 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: Also available are the operators [], ==, !=, +, *, ~, <<, >>, &, |, ^. Properties: bin -- The bitstring as a binary string. bool -- For single bit bitstrings, interpret as True or False. 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. 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 687 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, an array 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 mainly intended for use when initialising using 'bytes' or 'filename'.
Reimplemented in BitArray, ConstBitStream, and BitStream.
Definition at line 742 of file bitstring.py.
def __add__ | ( | self, | |
bs | |||
) |
Concatenate bitstrings and return new bitstring. bs -- the bitstring to append.
Reimplemented in ConstBitStream.
Definition at line 868 of file bitstring.py.
def __and__ | ( | self, | |
bs | |||
) |
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.
def __contains__ | ( | self, | |
bs | |||
) |
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 Bits for the copy module.
Reimplemented in BitArray, ConstBitStream, and BitStream.
Definition at line 850 of file bitstring.py.
def __eq__ | ( | self, | |
bs | |||
) |
Return True if two bitstrings have the same binary representation. >>> BitArray('0b1110') == '0xe' True
Definition at line 990 of file bitstring.py.
def __ge__ | ( | self, | |
other | |||
) |
Definition at line 865 of file bitstring.py.
def __getitem__ | ( | self, | |
key | |||
) |
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.
def __gt__ | ( | self, | |
other | |||
) |
Definition at line 859 of file bitstring.py.
def __hash__ | ( | self | ) |
Return an integer hash of the object.
Definition at line 1175 of file bitstring.py.
def __invert__ | ( | self | ) |
Return bitstring with every bit inverted. Raises Error if the bitstring is empty.
Definition at line 1012 of file bitstring.py.
def __le__ | ( | self, | |
other | |||
) |
Definition at line 862 of file bitstring.py.
def __len__ | ( | self | ) |
Return the length of the bitstring in bits.
Definition at line 938 of file bitstring.py.
def __lshift__ | ( | self, | |
n | |||
) |
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.
def __lt__ | ( | self, | |
other | |||
) |
Definition at line 856 of file bitstring.py.
def __mul__ | ( | self, | |
n | |||
) |
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.
def __ne__ | ( | self, | |
bs | |||
) |
Return False if two bitstrings have the same binary representation. >>> BitArray('0b111') == '0x7' False
Definition at line 1003 of file bitstring.py.
def __new__ | ( | cls, | |
auto = None , |
|||
length = None , |
|||
offset = None , |
|||
_cache = None , |
|||
** | kwargs | ||
) |
Definition at line 780 of file bitstring.py.
def __nonzero__ | ( | self | ) |
Return True if any bits are set to 1, otherwise return False.
Definition at line 1199 of file bitstring.py.
def __or__ | ( | self, | |
bs | |||
) |
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.
def __radd__ | ( | self, | |
bs | |||
) |
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.
def __rand__ | ( | self, | |
bs | |||
) |
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.
def __repr__ | ( | self | ) |
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.
def __rmul__ | ( | self, | |
n | |||
) |
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.
def __ror__ | ( | self, | |
bs | |||
) |
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.
def __rshift__ | ( | self, | |
n | |||
) |
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.
def __rxor__ | ( | self, | |
bs | |||
) |
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.
def __str__ | ( | self | ) |
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.
def __xor__ | ( | self, | |
bs | |||
) |
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.
|
protected |
Append a bitstring to the current bitstring.
Definition at line 2035 of file bitstring.py.
|
protected |
Check internal self consistency as a debugging aid.
Definition at line 1206 of file bitstring.py.
|
protected |
Reset the bitstring to an empty state.
Reimplemented in ConstBitStream.
Definition at line 1252 of file bitstring.py.
|
protected |
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.
|
protected |
Create and return a new copy of the Bits (always in memory).
Definition at line 2001 of file bitstring.py.
|
protected |
Delete bits at pos.
Definition at line 2135 of file bitstring.py.
|
protected |
Ensure the data is held in memory, not in a file.
Definition at line 1960 of file bitstring.py.
|
protected |
Quicker version of find when everything's whole byte and byte aligned.
Definition at line 2365 of file bitstring.py.
|
protected |
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.
|
protected |
Return interpretation as a binary string.
Definition at line 1872 of file bitstring.py.
|
protected |
Definition at line 1825 of file bitstring.py.
|
protected |
Return the data as an ordinary string.
Definition at line 1355 of file bitstring.py.
|
protected |
Interpret the whole bitstring as a float.
Definition at line 1586 of file bitstring.py.
|
protected |
Interpret the whole bitstring as a little-endian float.
Definition at line 1625 of file bitstring.py.
|
protected |
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.
|
protected |
Return data as a two's complement signed int.
Definition at line 1454 of file bitstring.py.
|
protected |
Return data as a big-endian two's complement signed int.
Definition at line 1490 of file bitstring.py.
|
protected |
Definition at line 1549 of file bitstring.py.
|
protected |
Return the length of the bitstring in bits.
Definition at line 1956 of file bitstring.py.
|
protected |
Return interpretation as an octal string.
Definition at line 1906 of file bitstring.py.
|
protected |
Definition at line 1953 of file bitstring.py.
|
protected |
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.
|
protected |
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.
|
protected |
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.
|
protected |
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.
|
protected |
Return data as an unsigned int.
Definition at line 1417 of file bitstring.py.
|
protected |
Return data as a big-endian two's complement unsigned int.
Definition at line 1472 of file bitstring.py.
|
protected |
Definition at line 1529 of file bitstring.py.
|
protected |
Definition at line 2243 of file bitstring.py.
|
protected |
Shift bits by n to the left in place. Return self.
Definition at line 2196 of file bitstring.py.
|
protected |
Concatenate n copies of self in place. Return self.
Definition at line 2210 of file bitstring.py.
|
protected |
Definition at line 1214 of file bitstring.py.
|
protected |
Definition at line 810 of file bitstring.py.
|
protected |
Definition at line 844 of file bitstring.py.
|
protected |
Helper function containing most of the __ior__, __iand__, __ixor__ code.
Definition at line 2224 of file bitstring.py.
|
protected |
Insert bs at pos.
Definition at line 2081 of file bitstring.py.
|
protected |
Flip bit at pos 1<->0.
Definition at line 2184 of file bitstring.py.
|
protected |
Invert every bit.
Definition at line 2189 of file bitstring.py.
|
protected |
Definition at line 2240 of file bitstring.py.
|
protected |
Shift bits by n to the right in place. Return self.
Definition at line 2203 of file bitstring.py.
|
protected |
Definition at line 2246 of file bitstring.py.
|
protected |
Overwrite with bs at pos.
Definition at line 2102 of file bitstring.py.
|
protected |
Prepend a bitstring to the current bitstring.
Definition at line 2039 of file bitstring.py.
|
protected |
Read bits and interpret as a binary string.
Definition at line 1855 of file bitstring.py.
|
protected |
Read some bits from the bitstring and return newly constructed bitstring.
Definition at line 2249 of file bitstring.py.
|
protected |
Definition at line 1831 of file bitstring.py.
|
protected |
Read bytes and return them. Note that length is in bits.
Definition at line 1346 of file bitstring.py.
|
protected |
Read bits and interpret as a float.
Definition at line 1568 of file bitstring.py.
|
protected |
Read bits and interpret as a little-endian float.
Definition at line 1606 of file bitstring.py.
|
protected |
Read bits and interpret as a hex string.
Definition at line 1928 of file bitstring.py.
|
protected |
Read bits and interpret as a signed int
Definition at line 1444 of file bitstring.py.
|
protected |
Read bits and interpret as a big-endian signed int.
Definition at line 1483 of file bitstring.py.
|
protected |
Read bits and interpret as a little-endian signed int.
Definition at line 1539 of file bitstring.py.
|
protected |
Definition at line 2288 of file bitstring.py.
|
protected |
Read bits and interpret as an octal string.
Definition at line 1891 of file bitstring.py.
|
protected |
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.
|
protected |
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.
|
protected |
Reads a token from the bitstring and returns the result.
Definition at line 2019 of file bitstring.py.
|
protected |
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.
|
protected |
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.
|
protected |
Read bits and interpret as an unsigned int.
Definition at line 1399 of file bitstring.py.
|
protected |
Read bits and interpret as a big-endian unsigned int.
Definition at line 1465 of file bitstring.py.
|
protected |
Read bits and interpret as a little-endian unsigned int.
Definition at line 1501 of file bitstring.py.
|
protected |
Reverse all bits in-place.
Definition at line 2043 of file bitstring.py.
|
protected |
Reverse bytes in-place.
Definition at line 2161 of file bitstring.py.
|
protected |
Set bit at pos to 1.
Definition at line 2174 of file bitstring.py.
|
protected |
Set bitstring from a bitstring, file, bool, integer, array, iterable or string.
Definition at line 1256 of file bitstring.py.
|
protected |
Reset the bitstring to the value given in binstring.
Definition at line 1834 of file bitstring.py.
|
protected |
Same as _setbin_safe, but input isn't sanity checked. binstring mustn't start with '0b'.
Definition at line 1841 of file bitstring.py.
|
protected |
Definition at line 1815 of file bitstring.py.
|
protected |
Set the data from a string.
Definition at line 1325 of file bitstring.py.
|
protected |
Unchecked version of _setbytes_safe.
Definition at line 1341 of file bitstring.py.
|
protected |
Use file as source of bits.
Definition at line 1310 of file bitstring.py.
|
protected |
Definition at line 1552 of file bitstring.py.
|
protected |
Definition at line 1590 of file bitstring.py.
|
protected |
Reset the bitstring to have the value given in hexstring.
Definition at line 1910 of file bitstring.py.
|
protected |
Reset the bitstring to have given signed int interpretation.
Definition at line 1421 of file bitstring.py.
|
protected |
Set bitstring to a big-endian signed int interpretation.
Definition at line 1476 of file bitstring.py.
|
protected |
Definition at line 1532 of file bitstring.py.
|
protected |
Reset the bitstring to have the value given in octstring.
Definition at line 1876 of file bitstring.py.
|
protected |
Initialise bitstring with signed exponential-Golomb code for integer i.
Definition at line 1690 of file bitstring.py.
|
protected |
Initialise bitstring with signed interleaved exponential-Golomb code for integer i.
Definition at line 1773 of file bitstring.py.
|
protected |
Initialise bitstring with unsigned exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1629 of file bitstring.py.
|
protected |
Initialise bitstring with unsigned interleaved exponential-Golomb code for integer i. Raises CreationError if i < 0.
Definition at line 1728 of file bitstring.py.
|
protected |
Reset the bitstring to have given unsigned int interpretation.
Definition at line 1362 of file bitstring.py.
|
protected |
Set the bitstring to a big-endian unsigned int interpretation.
Definition at line 1458 of file bitstring.py.
|
protected |
Definition at line 1494 of file bitstring.py.
|
protected |
Used internally to get a slice, without error checking.
Definition at line 2008 of file bitstring.py.
|
protected |
Truncate bits from the end of the bitstring.
Definition at line 2068 of file bitstring.py.
|
protected |
Truncate bits from the start of the bitstring.
Definition at line 2055 of file bitstring.py.
|
protected |
Set bit at pos to 0.
Definition at line 2179 of file bitstring.py.
|
protected |
Validate start and end and return them as positive bit positions.
Definition at line 2253 of file bitstring.py.
def all | ( | self, | |
value, | |||
pos = None |
|||
) |
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.
def any | ( | self, | |
value, | |||
pos = None |
|||
) |
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 count | ( | self, | |
value | |||
) |
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.
def cut | ( | self, | |
bits, | |||
start = None , |
|||
end = None , |
|||
count = None |
|||
) |
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.
def endswith | ( | self, | |
suffix, | |||
start = None , |
|||
end = None |
|||
) |
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.
def find | ( | self, | |
bs, | |||
start = None , |
|||
end = None , |
|||
bytealigned = None |
|||
) |
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.
def findall | ( | self, | |
bs, | |||
start = None , |
|||
end = None , |
|||
count = None , |
|||
bytealigned = None |
|||
) |
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.
def join | ( | self, | |
sequence | |||
) |
Return concatenation of bitstrings joined by self. sequence -- A sequence of bitstrings.
Definition at line 2637 of file bitstring.py.
def rfind | ( | self, | |
bs, | |||
start = None , |
|||
end = None , |
|||
bytealigned = None |
|||
) |
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.
def split | ( | self, | |
delimiter, | |||
start = None , |
|||
end = None , |
|||
count = None , |
|||
bytealigned = None |
|||
) |
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.
def startswith | ( | self, | |
prefix, | |||
start = None , |
|||
end = None |
|||
) |
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.
def tobytes | ( | self | ) |
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.
def tofile | ( | self, | |
f | |||
) |
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.
def unpack | ( | self, | |
fmt, | |||
** | kwargs | ||
) |
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.
|
staticprivate |
Definition at line 1204 of file bitstring.py.
|
staticprivate |
Definition at line 740 of file bitstring.py.
|
protected |
Definition at line 1254 of file bitstring.py.
|
staticprotected |
Definition at line 2803 of file bitstring.py.
|
staticprotected |
Definition at line 2809 of file bitstring.py.
|
staticprotected |
Definition at line 2806 of file bitstring.py.
|
protected |
Definition at line 1170 of file bitstring.py.
|
staticprotected |
Definition at line 2802 of file bitstring.py.
|
staticprotected |
Definition at line 2808 of file bitstring.py.
|
staticprotected |
Definition at line 2805 of file bitstring.py.
|
staticprotected |
Definition at line 2801 of file bitstring.py.
|
staticprotected |
Definition at line 2807 of file bitstring.py.
|
staticprotected |
Definition at line 2804 of file bitstring.py.
|
static |
Definition at line 2810 of file bitstring.py.
|
staticprotected |
Definition at line 2821 of file bitstring.py.
|
static |
Definition at line 2835 of file bitstring.py.
|
static |
Definition at line 2829 of file bitstring.py.
|
static |
Definition at line 2841 of file bitstring.py.
|
static |
Definition at line 2850 of file bitstring.py.
|
static |
Definition at line 2859 of file bitstring.py.
|
static |
Definition at line 2868 of file bitstring.py.
|
static |
Definition at line 2877 of file bitstring.py.
|
static |
Definition at line 2832 of file bitstring.py.
|
static |
Definition at line 2844 of file bitstring.py.
|
static |
Definition at line 2853 of file bitstring.py.
|
static |
Definition at line 2862 of file bitstring.py.
|
static |
Definition at line 2871 of file bitstring.py.
|
static |
Definition at line 2823 of file bitstring.py.
|
static |
Definition at line 2826 of file bitstring.py.
|
static |
Definition at line 2838 of file bitstring.py.
|
static |
Definition at line 2883 of file bitstring.py.
|
static |
Definition at line 2889 of file bitstring.py.
|
static |
Definition at line 2880 of file bitstring.py.
|
static |
Definition at line 2886 of file bitstring.py.
|
static |
Definition at line 2847 of file bitstring.py.
|
static |
Definition at line 2856 of file bitstring.py.
|
static |
Definition at line 2865 of file bitstring.py.
|
static |
Definition at line 2874 of file bitstring.py.