Work around bug with empty 1P entries containing single 0x10 Byte.

This commit is contained in:
Markus Birth 2021-08-22 21:47:01 +02:00
parent 984c27e6c1
commit a39ca6b2c4
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A

View File

@ -130,6 +130,9 @@ class OnepifEntry():
continue
propname = f["designation"]
propval = f["value"]
if type(propval) is str:
# For some reason 1P sometimes exports 0x10 character for empty strings
propval = propval.replace("\x10", "")
if f["type"] not in ["T", "P", "E"]:
raise Exception("Unknown field type discovered: {}".format(f["type"]))
self.add_with_unique_key(target_dict, propname, propval)
@ -157,6 +160,9 @@ class OnepifEntry():
while new_key2 in props:
suffix_ctr2 += 1
new_key2 = "{}_{}".format(k2, suffix_ctr2)
if type(v2) is str:
# For some reason 1P sometimes exports 0x10 character for empty strings
v2 = v2.replace("\x10", "")
props[new_key2] = v2
continue
new_key = k
@ -164,6 +170,9 @@ class OnepifEntry():
while new_key in props:
suffix_ctr += 1
new_key = "{}_{}".format(k, suffix_ctr)
if type(v) is str:
# For some reason 1P sometimes exports 0x10 character for empty strings
v = v.replace("\x10", "")
props[new_key] = v
# TODO: Maybe walk all keys and see if there's (xxx_dd), xxx_mm, xxx_yy and turn them into a date
return props