-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from cjstep/ext-py-parquet-bitstring-fix
[core] fixing extra bracket and missing paren in ext-py/parquet/bitstring.py
- Loading branch information
Showing
1 changed file
with
3 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
|
||
SINGLE_BIT_MASK = [1 << x for x in range(7, -1, -1)] | ||
|
||
] | ||
|
||
class BitString(object): | ||
|
||
def __init__(self, bytes, length=None, offset=None): | ||
self.bytes = bytes | ||
self.offset = offset if offset is not None else 0 | ||
self.length = length if length is not None else 8 * len(data) - self.offset | ||
|
||
|
||
def __getitem__(self, key): | ||
try: | ||
start = key.start | ||
stop = key.stop | ||
except AttributeError: | ||
if key < 0 or key >= length: | ||
raise IndexError() | ||
byte_index, bit_offset = divmod(self.offset + key), 8) | ||
return self.bytes[byte_index] & SINGLE_BIT_MASK[bit_offset] | ||
byte_index, bit_offset = (divmod(self.offset + key), 8) | ||
return self.bytes[byte_index] & SINGLE_BIT_MASK[bit_offset] | ||
|