/usr/lib/python3/dist-packages/bitstruct-3.4.0.egg-info/PKG-INFO is in python3-bitstruct 3.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | Metadata-Version: 1.1
Name: bitstruct
Version: 3.4.0
Summary: This module performs conversions between Python values and C bit field structs represented as Python byte strings.
Home-page: https://github.com/eerimoq/bitstruct
Author: Erik Moqvist, Ilya Petukhov
Author-email: erik.moqvist@gmail.com
License: MIT
Description: |buildstatus|_
About
=====
This module is intended to have a similar interface as the python
struct module, but working on bits instead of primitive data types
(char, int, ...).
Documentation: http://bitstruct.readthedocs.org/en/latest
Installation
============
.. code-block:: python
pip install bitstruct
Example usage
=============
See the test suite: https://github.com/eerimoq/bitstruct/blob/master/tests/test_bitstruct.py
A basic example of packing/unpacking four integers:
.. code-block:: python
>>> from bitstruct import *
>>> pack('u1u3u4s16', 1, 2, 3, -4)
b'\xa3\xff\xfc'
>>> unpack('u1u3u4s16', b'\xa3\xff\xfc')
(1, 2, 3, -4)
>>> calcsize('u1u3u4s16')
24
The unpacked fields can be named by assigning them to variables or by
wrapping the result in a named tuple:
.. code-block:: python
>>> from bitstruct import *
>>> from collections import namedtuple
>>> MyName = namedtuple('myname', [ 'a', 'b', 'c', 'd' ])
>>> unpacked = unpack('u1u3u4s16', b'\xa3\xff\xfc')
>>> myname = MyName(*unpacked)
>>> myname
myname(a=1, b=2, c=3, d=-4)
>>> myname.c
3
An example of packing/unpacking a unsinged integer, a signed integer,
a float, a boolean, a byte string and a string:
.. code-block:: python
>>> from bitstruct import *
>>> pack('u5s5f32b1r13t40', 1, -1, 3.75, True, b'\xff\xff', u'hello')
b'\x0f\xd0\x1c\x00\x00?\xffhello'
>>> unpack('u5s5f32b1r13t40', b'\x0f\xd0\x1c\x00\x00?\xffhello')
(1, -1, 3.75, True, b'\xff\xf8', u'hello')
>>> calcsize('u5s5f32b1r13t24')
80
The same format and values as in the previous example, but using LSB
(Least Significant Bit) first instead of the default MSB (Most
Significant Bit) first:
.. code-block:: python
>>> from bitstruct import *
>>> pack('<u5s5f32b1r13', 1, -1, 3.75, True, b'\xff\xff')
b'\x87\xc0\x00\x03\x80\xbf\xff'
>>> unpack('<u5s5f32b1r13', b'\x87\xc0\x00\x03\x80\xbf\xff')
(1, -1, 3.75, True, b'\xff\xf8')
>>> calcsize('<u5s5f32b1r13')
56
An example of unpacking values from a hexstring and a binary file:
.. code-block:: python
>>> from bitstruct import *
>>> unpack('s17s13r24', '0123456789abcdef'.decode('hex'))
(582, -3751, b'\xe2j\xf3')
>>> with open("test.bin", "rb") as fin:
... unpack('s17s13r24', fin.read(8))
...
...
(582, -3751, b'\xe2j\xf3')
Change endianness of the data with byteswap(), and then unpack the
values:
.. code-block:: python
>>> from bitstruct import *
>>> packed = pack('u1u3u4s16', 1, 2, 3, 1)
>>> unpack('u1u3u4s16', byteswap('12', packed))
(1, 2, 3, 256)
.. |buildstatus| image:: https://travis-ci.org/eerimoq/bitstruct.svg
.. _buildstatus: https://travis-ci.org/eerimoq/bitstruct
Keywords: bit field,bit parsing,bit unpack,bit pack
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
|