From a39ca6b2c496c844d070a3211686d133951ac622 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 22 Aug 2021 21:47:01 +0200 Subject: [PATCH] Work around bug with empty 1P entries containing single 0x10 Byte. --- onepif/OnepifEntry.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/onepif/OnepifEntry.py b/onepif/OnepifEntry.py index 417947f..3734baf 100644 --- a/onepif/OnepifEntry.py +++ b/onepif/OnepifEntry.py @@ -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