mirror of
https://github.com/dgelessus/python-rsrcfork.git
synced 2024-11-26 11:49:23 +00:00
Make _hexdump behave more like "hexdump -C"
This commit is contained in:
parent
c207703c9f
commit
5dbec5d905
@ -85,7 +85,8 @@ Command-line interface
|
|||||||
$ python3 -m rsrcfork /Users/Shared/Test.textClipping "'TEXT' (256)"
|
$ python3 -m rsrcfork /Users/Shared/Test.textClipping "'TEXT' (256)"
|
||||||
Resource 'TEXT' (256), unnamed, no attributes, 17 bytes:
|
Resource 'TEXT' (256), unnamed, no attributes, 17 bytes:
|
||||||
00000000 48 65 72 65 20 69 73 20 73 6f 6d 65 20 74 65 78 |Here is some tex|
|
00000000 48 65 72 65 20 69 73 20 73 6f 6d 65 20 74 65 78 |Here is some tex|
|
||||||
00000010 74 |t |
|
00000010 74 |t|
|
||||||
|
00000011
|
||||||
|
|
||||||
|
|
||||||
Limitations
|
Limitations
|
||||||
@ -142,6 +143,7 @@ Version 1.1.1
|
|||||||
`````````````
|
`````````````
|
||||||
|
|
||||||
* Fixed overflow issue with empty resource files or empty resource type entries
|
* Fixed overflow issue with empty resource files or empty resource type entries
|
||||||
|
* Changed ``_hexdump`` to behave more like ``hexdump -C``
|
||||||
|
|
||||||
Version 1.1.0
|
Version 1.1.0
|
||||||
`````````````
|
`````````````
|
||||||
|
@ -577,7 +577,10 @@ def _hexdump(data: bytes):
|
|||||||
line = data[i:i + 16]
|
line = data[i:i + 16]
|
||||||
line_hex = " ".join(f"{byte:02x}" for byte in line)
|
line_hex = " ".join(f"{byte:02x}" for byte in line)
|
||||||
line_char = line.decode("MacRoman").translate(_TRANSLATE_NONPRINTABLES)
|
line_char = line.decode("MacRoman").translate(_TRANSLATE_NONPRINTABLES)
|
||||||
print(f"{i:08x} {line_hex:<{16*2+15}} |{line_char:<16}|")
|
print(f"{i:08x} {line_hex:<{16*2+15}} |{line_char}|")
|
||||||
|
|
||||||
|
if data:
|
||||||
|
print(f"{len(data):08x}")
|
||||||
|
|
||||||
def _raw_hexdump(data: bytes):
|
def _raw_hexdump(data: bytes):
|
||||||
for i in range(0, len(data), 16):
|
for i in range(0, len(data), 16):
|
||||||
|
Loading…
Reference in New Issue
Block a user