easybits 0.1.3__tar.gz → 0.1.4__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {easybits-0.1.3 → easybits-0.1.4}/PKG-INFO +4 -2
- {easybits-0.1.3 → easybits-0.1.4}/easybits/__init__.py +9 -4
- {easybits-0.1.3 → easybits-0.1.4}/pyproject.toml +1 -1
- {easybits-0.1.3 → easybits-0.1.4}/README.md +0 -0
- {easybits-0.1.3 → easybits-0.1.4}/easybits/errors.py +0 -0
- {easybits-0.1.3 → easybits-0.1.4}/easybits/util.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: easybits
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: A friendly interface for exploring bits.
|
5
5
|
Author: Chris Proctor
|
6
6
|
Author-email: chris@chrisproctor.net
|
@@ -9,6 +9,8 @@ Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.9
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
12
14
|
Requires-Dist: bitarray (>=3.0.0,<4.0.0)
|
13
15
|
Description-Content-Type: text/markdown
|
14
16
|
|
@@ -17,6 +17,8 @@ class Bits(bitarray):
|
|
17
17
|
- Integers are always signed.
|
18
18
|
"""
|
19
19
|
|
20
|
+
default_text_encoding = 'ascii'
|
21
|
+
|
20
22
|
@classmethod
|
21
23
|
def zeros(cls, length):
|
22
24
|
return Bits(zeros(length))
|
@@ -25,7 +27,7 @@ class Bits(bitarray):
|
|
25
27
|
def ones(cls, length):
|
26
28
|
return Bits(ones(length))
|
27
29
|
|
28
|
-
def __new__(cls, value=None, length=None, encoding=
|
30
|
+
def __new__(cls, value=None, length=None, encoding=None):
|
29
31
|
if value is None:
|
30
32
|
bits = bitarray(length or 0)
|
31
33
|
elif isinstance(value, bytes):
|
@@ -38,11 +40,14 @@ class Bits(bitarray):
|
|
38
40
|
raise IntegersRequireLength()
|
39
41
|
bits = int2ba(value, length=length, signed=True)
|
40
42
|
elif isinstance(value, str):
|
41
|
-
if
|
43
|
+
if encoding:
|
44
|
+
bits = bitarray()
|
45
|
+
bits.frombytes(value.encode(encoding))
|
46
|
+
elif is_bit_string(value):
|
42
47
|
bits = bitarray(value)
|
43
48
|
else:
|
44
49
|
bits = bitarray()
|
45
|
-
bits.frombytes(value.encode(
|
50
|
+
bits.frombytes(value.encode(cls.default_text_encoding))
|
46
51
|
elif isinstance(value, list):
|
47
52
|
bits = bitarray(value)
|
48
53
|
elif isinstance(value, bitarray):
|
@@ -96,7 +101,7 @@ class Bits(bitarray):
|
|
96
101
|
return result
|
97
102
|
|
98
103
|
def __sub__(self, other):
|
99
|
-
"""Performs bitwise
|
104
|
+
"""Performs bitwise subtraction on `self` and `other`. Does not
|
100
105
|
check for overflow.
|
101
106
|
"""
|
102
107
|
a, b = self, Bits(other)
|
File without changes
|
File without changes
|
File without changes
|