Work around bug with empty 1P entries containing single 0x10 Byte.
This commit is contained in:
parent
984c27e6c1
commit
a39ca6b2c4
@ -130,6 +130,9 @@ class OnepifEntry():
|
|||||||
continue
|
continue
|
||||||
propname = f["designation"]
|
propname = f["designation"]
|
||||||
propval = f["value"]
|
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"]:
|
if f["type"] not in ["T", "P", "E"]:
|
||||||
raise Exception("Unknown field type discovered: {}".format(f["type"]))
|
raise Exception("Unknown field type discovered: {}".format(f["type"]))
|
||||||
self.add_with_unique_key(target_dict, propname, propval)
|
self.add_with_unique_key(target_dict, propname, propval)
|
||||||
@ -157,6 +160,9 @@ class OnepifEntry():
|
|||||||
while new_key2 in props:
|
while new_key2 in props:
|
||||||
suffix_ctr2 += 1
|
suffix_ctr2 += 1
|
||||||
new_key2 = "{}_{}".format(k2, suffix_ctr2)
|
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
|
props[new_key2] = v2
|
||||||
continue
|
continue
|
||||||
new_key = k
|
new_key = k
|
||||||
@ -164,6 +170,9 @@ class OnepifEntry():
|
|||||||
while new_key in props:
|
while new_key in props:
|
||||||
suffix_ctr += 1
|
suffix_ctr += 1
|
||||||
new_key = "{}_{}".format(k, suffix_ctr)
|
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
|
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
|
# TODO: Maybe walk all keys and see if there's (xxx_dd), xxx_mm, xxx_yy and turn them into a date
|
||||||
return props
|
return props
|
||||||
|
Loading…
x
Reference in New Issue
Block a user