check.py : Ignore new duplicates created by convert_guids.

This commit is contained in:
Philippe Groarke 2018-01-11 14:51:54 -05:00
parent 6f173f0069
commit 7cd223f648

View file

@ -204,7 +204,7 @@ class Mapping:
def convert_guid(self): def convert_guid(self):
if self.platform == "Windows": if self.platform == "Windows":
if self.guid[20:32] != "504944564944": if self.guid[20:32] != "504944564944":
return return False
guid = self.guid guid = self.guid
guid = guid[:20] + "000000000000" guid = guid[:20] + "000000000000"
@ -212,24 +212,28 @@ class Mapping:
guid = guid[:8] + guid[:4] + guid[12:] guid = guid[:8] + guid[:4] + guid[12:]
guid = "03000000" + guid[8:] guid = "03000000" + guid[8:]
guid = guid.lower() guid = guid.lower()
print("Converted %s GUID. From %s to %s" % (self.name, self.guid, print("%s : Converted %s GUID. From %s to %s" \
guid)) %(self.platform, self.name, self.guid, guid))
self.guid = guid self.guid = guid
elif self.platform == "Mac OS X": elif self.platform == "Mac OS X":
if self.guid[4:16] != "000000000000" \ if self.guid[4:16] != "000000000000" \
or self.guid[20:32] != "000000000000": or self.guid[20:32] != "000000000000":
return return False
guid = self.guid guid = self.guid
guid = guid[:20] + "000000000000" guid = guid[:20] + "000000000000"
guid = guid[:8] + guid[:4] + guid[12:] guid = guid[:8] + guid[:4] + guid[12:]
guid = "03000000" + guid[8:] guid = "03000000" + guid[8:]
guid = guid.lower() guid = guid.lower()
print("Converted %s GUID. From %s to %s" % (self.name, self.guid, print("%s : Converted %s GUID. From %s to %s" \
guid)) % (self.platform, self.name, self.guid, guid))
self.guid = guid self.guid = guid
else:
return False
return True
def import_header(filepath, debug_out = False): def import_header(filepath, debug_out = False):
class Platform: class Platform:
@ -360,7 +364,17 @@ def main():
"output mode...") "output mode...")
for platform,p_dict in mappings_dict.items(): for platform,p_dict in mappings_dict.items():
for guid,mapping in p_dict.items(): for guid,mapping in p_dict.items():
mapping.convert_guid() if mapping.convert_guid():
del mappings_dict[platform][guid]
if mapping.guid in mappings_dict[platform]:
print("\nDuplicate detected when converting GUID.")
prev_mapping = mappings_dict[platform][mapping.guid]
print("Previous mapping %s" % prev_mapping.name)
print("Ignoring new mapping")
print(mapping.serialize())
print("\n")
continue
mappings_dict[platform][mapping.guid] = mapping
if args.import_header is not None: if args.import_header is not None:
print("Importing mappings from SDL_gamecontrollerdb.h.") print("Importing mappings from SDL_gamecontrollerdb.h.")