import sys
import os
import numpy as np
if len(sys.argv)!=2:
raise "Es muss eine Datei als Kommandozeilenargument angegeben werden."
file = sys.argv[1]
if not os.path.exists(file):
raise f"Datei {file} nicht gefunden!"
with open(file, "rb") as f:
binData = f.read()
group = 4
for i in range(0, len(binData), group):
line = "%04d | " % i
for j in range(i, min(len(binData),i+group)):
zweier = format(binData[j], "08b")
line += zweier[0:4]+"_"+zweier[4:]+" "
line += " | "
for j in range(i, min(len(binData),i+group)):
line +="%02x " % binData[j]
line += " | "
for j in range(i, min(len(binData),i+group)):
line +="%3d " % binData[j]
line += " | "
for j in range(i, min(len(binData),i+group)):
if (binData[j]<127 and binData[j]>32):
line += chr(binData[j])
else:
line += " "
print(line)