Move parse.py to library repository

This commit is contained in:
Queen Vinyl Da.i'gyu-Kazotetsu committed 2025-08-09 03:21:16 -07:00
1 parent 92cfe365f4
commit dcbd80e244
3 files changed
+2 -277

No files matched your search

+1 -28
View File
@@ -12,34 +12,7 @@ from datetime import datetime
if not sys.version_info >= (3, 6):
raise Exception("Python 3.6 or higher is required!")
# Byte conversions
def bytes_to_string(data):
return data.decode('ascii').replace('\x00', ' ').strip()
def bytes_to_hex(data, chunkify = False):
output = data.hex().upper()
return " ".join((output[0+i:2+i] for i in range(0, len(output), 2))) if chunkify else output
def bytes_to_int(data):
return int.from_bytes(data, 'little')
def bytes_to_float(data):
return struct.unpack('<f', data)[0]
def bytes_to_date(data):
string = bytes_to_string(data)
parts = string.split("_")
if len(parts) < 5:
return string # Not a date we can process, if it's a date at all
return datetime(
year=int(parts[0]),
month=int(parts[1]),
day=int(parts[2]),
hour=int(parts[3]),
minute=int(parts[4])
)
#Some keys come surrounded in terminal color codes such as "63654db94d97"
#We need to remove these
def strip_color_codes(input_string):