Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
S Groesz | 49ef87f8c9 | |
S Groesz | ecc1b3bd8d | |
S Groesz | 55ae3544d5 | |
S Groesz | de7c42fe8f | |
S Groesz | 34fa1b4502 |
14
README.md
14
README.md
|
@ -8,6 +8,20 @@ Intended to be compatible with Python 3.6+. Written and tested against Python
|
|||
If something doesn't work in Python 3.6, it's a bug. Please report any such
|
||||
bugs if they are encountered.
|
||||
|
||||
# PyPI
|
||||
|
||||
View on PyPI at [https://pypi.org/project/binary-bits/](https://pypi.org/project/binary-bits/)
|
||||
|
||||
Install from PyPI:
|
||||
python3 -m pip install binary-bits --upgrade
|
||||
|
||||
Use in your project:
|
||||
```python
|
||||
import bits
|
||||
|
||||
my_bytes = bits.Bytes(bytes.fromhex('deadbeef'))
|
||||
```
|
||||
|
||||
# Similar projects
|
||||
## [py-flags](https://pypi.org/project/py-flags/)
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
Steps to publish to PyPI:
|
||||
|
||||
1) run `make test`
|
||||
2) update version in setup.py
|
||||
3) Tag the current release in git to match the version in setup.py
|
||||
git tag -a 1.2.0 -m 'Release 1.2.0'
|
||||
4) commit any pending changes to git
|
||||
git add .
|
||||
git commit -m 'commit changes'
|
||||
git push origin 1.2.0
|
||||
5) test publish
|
||||
./publish.sh test
|
||||
6) publish to PyPI
|
||||
./publish.sh pypi
|
||||
|
4
setup.py
4
setup.py
|
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||
|
||||
setuptools.setup(
|
||||
name="binary-bits",
|
||||
version="1.1.0",
|
||||
version="1.1.1",
|
||||
author="S Groesz",
|
||||
description="Provide additional methods for working with binary data",
|
||||
long_description=long_description,
|
||||
|
@ -28,6 +28,6 @@ setuptools.setup(
|
|||
'test': ['coverage'],
|
||||
},
|
||||
project_urls={
|
||||
'Source': 'http://git.groesz.org/wp/bits/',
|
||||
'Source': 'http://git.groesz.org/Groesz.org/bits/',
|
||||
},
|
||||
)
|
||||
|
|
12
src/bits.py
12
src/bits.py
|
@ -930,12 +930,12 @@ class Bits:
|
|||
|
||||
class Bytes:
|
||||
"""
|
||||
A colletion of Bits with convenient properties for working with binary data
|
||||
A collection of Bits with convenience methods for working with binary data
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
def __init__(self, var=None, byteorder="big"):
|
||||
def __init__(self, var=None, byteorder="big", bits=None):
|
||||
"""
|
||||
var: a supported variant (object)
|
||||
byteorder: notimplemented, mostly ignored
|
||||
|
@ -943,11 +943,17 @@ class Bytes:
|
|||
self.__raw = bytearray(b'')
|
||||
self.__small = False
|
||||
self.__iter = None
|
||||
self.__list_len = None
|
||||
self.__bit_len = None
|
||||
if byteorder.lower() in ["small", "little"]:
|
||||
self.__small = True
|
||||
if var is not None:
|
||||
self.__raw = self.__to_bytearray(var)
|
||||
if bits is None:
|
||||
self.__bit_len = len(self.__raw)
|
||||
else:
|
||||
if not isinstance(bits, (int, Bytes, Bit)):
|
||||
raise TypeError(f"bits argument must be int, not {type(bits)}")
|
||||
self.__bit_len = int(bits)
|
||||
|
||||
def __bytes__(self):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue