diff --git a/pytiled_parser/parsers/json/tiled_object.py b/pytiled_parser/parsers/json/tiled_object.py index 260ef90f..527cf15e 100644 --- a/pytiled_parser/parsers/json/tiled_object.py +++ b/pytiled_parser/parsers/json/tiled_object.py @@ -325,13 +325,13 @@ def parse( raw_object["properties"] = [] for prop in loaded_template["properties"]: - + found = False for prop2 in raw_object["properties"]: if prop2["name"] == prop["name"]: found = True break - + if not found: raw_object["properties"].append(prop) else: diff --git a/pytiled_parser/parsers/tmx/tiled_object.py b/pytiled_parser/parsers/tmx/tiled_object.py index 498685ee..a2e16d53 100644 --- a/pytiled_parser/parsers/tmx/tiled_object.py +++ b/pytiled_parser/parsers/tmx/tiled_object.py @@ -277,24 +277,26 @@ def parse(raw_object: etree.Element, parent_dir: Optional[Path] = None) -> Tiled continue new_object.attrib[key] = val - properties_element = raw_object.find("./properties") temp_properties_element = new_object.find("./properties") if properties_element is not None and temp_properties_element is None: new_object.append(properties_element) elif properties_element is None and temp_properties_element is not None: pass - elif properties_element is not None and temp_properties_element is not None: + elif ( + properties_element is not None + and temp_properties_element is not None + ): for prop in temp_properties_element: - - found = False - for prop2 in properties_element: - if prop.attrib["name"] == prop2.attrib["name"]: - found = True - break - - if not found: - properties_element.append(prop) + + found = False + for prop2 in properties_element: + if prop.attrib["name"] == prop2.attrib["name"]: + found = True + break + + if not found: + properties_element.append(prop) new_object.remove(temp_properties_element) new_object.append(properties_element)