mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-24 06:35:42 +00:00
compatibility_xml_to_csv.py: Fix handling of broken input
This commit is contained in:
parent
fb443ea5f5
commit
77da1c8f02
|
@ -13,9 +13,15 @@ def convert_list(filename, separator=','):
|
||||||
print("!!! Skipping invalid tag '%s'" % child.tag)
|
print("!!! Skipping invalid tag '%s'" % child.tag)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
game_code = child.get("code") or ""
|
game_code = child.get("code")
|
||||||
|
if game_code is None:
|
||||||
|
game_code = ""
|
||||||
game_title = child.get("title") or ""
|
game_title = child.get("title") or ""
|
||||||
region = child.get("region") or ""
|
if game_title is None:
|
||||||
|
game_title = ""
|
||||||
|
region = child.get("region")
|
||||||
|
if region is None:
|
||||||
|
region = ""
|
||||||
|
|
||||||
node = child.find("compatibility")
|
node = child.find("compatibility")
|
||||||
compatibility = node.text if node is not None else ""
|
compatibility = node.text if node is not None else ""
|
||||||
|
@ -28,11 +34,11 @@ def convert_list(filename, separator=','):
|
||||||
|
|
||||||
fix = None
|
fix = None
|
||||||
if separator == '\t':
|
if separator == '\t':
|
||||||
fix = lambda x: x.replace('\t', ' ')
|
fix = lambda x: "" if x is None else x.replace('\t', ' ')
|
||||||
elif separator == ',':
|
elif separator == ',':
|
||||||
fix = lambda x: x if x.find(',') < 0 else ("\"%s\"" % x)
|
fix = lambda x: "" if x is None else x if x.find(',') < 0 else ("\"%s\"" % x)
|
||||||
else:
|
else:
|
||||||
fix = lambda x: x
|
fix = lambda x: "" if x is None else x
|
||||||
|
|
||||||
entry_fields = [fix(game_code), fix(game_title), fix(region), fix(compatibility), fix(upscaling_issues), fix(version_tested), fix(comments)]
|
entry_fields = [fix(game_code), fix(game_title), fix(region), fix(compatibility), fix(upscaling_issues), fix(version_tested), fix(comments)]
|
||||||
output += separator.join(entry_fields) + "\n"
|
output += separator.join(entry_fields) + "\n"
|
||||||
|
|
Loading…
Reference in a new issue