Skip to content

Commit

Permalink
Fix and simplify reading and seeking in olecf/thumbs
Browse files Browse the repository at this point in the history
pylinting to fix various bugs and code smells
  • Loading branch information
MosesofEgypt committed Jan 28, 2025
1 parent 3759292 commit e6b5621
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 488 deletions.
4 changes: 2 additions & 2 deletions supyr_struct/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
# ##############
__author__ = "Sigmmma"
# YYYY.MM.DD
__date__ = "2025.01.18"
__version__ = (1, 7, 0)
__date__ = "2020.10.30"
__version__ = (1, 5, 4)
__website__ = "https://github.com/Sigmmma/supyr_struct"


Expand Down
11 changes: 4 additions & 7 deletions supyr_struct/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,11 @@ def peek(self, count=None, offset=None):
Reads and returns 'count' number of bytes without
changing the current read/write pointer position.
'''
if offset is None:
pos = self._pos
else:
pos = offset
pos = self._pos if offset is None else offset
try:
if pos + count < len(self):
return self[pos:pos + count]
return self[pos:pos + len(self)]
len_self = len(self)
peek_end = pos + count
return self[pos: len_self if peek_end >= len_self else peek_end]
except TypeError:
pass

Expand Down
2 changes: 1 addition & 1 deletion supyr_struct/defs/audio/wav.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def read_write_id3_data_size(
# are ignored, so a 257 bytes long tag is represented as $00 00 02 01.
if writebuffer is not None:
buffer.write(bytes(
(size >> (7 * (3 - i))) & 0x7F
(val >> (7 * (3 - i))) & 0x7F
for i, val in enumerate([parent.frame_data_size] * 4)
))
else:
Expand Down
Loading

0 comments on commit e6b5621

Please sign in to comment.