texrename: handle multiple files with the same CRC too

This commit is contained in:
fgsfds 2020-05-28 23:08:32 +03:00
parent a0a256499b
commit 85a1d88422

View File

@ -40,7 +40,7 @@ except OSError as e:
sys.exit(2) sys.exit(2)
# load the CRC map # load the CRC map
crcmap = dict() crcmap = list()
try: try:
with open(mapfname, 'r') as f: with open(mapfname, 'r') as f:
for line in f: for line in f:
@ -53,7 +53,7 @@ try:
crc = int(crcstr[2:], 16) crc = int(crcstr[2:], 16)
else: else:
crc = int(crcstr) crc = int(crcstr)
crcmap[crc] = os.path.join(outpath, tok[1].strip()) crcmap.append((crc, os.path.join(outpath, tok[1].strip())))
except OSError as e: except OSError as e:
print('could not open {0}: {1}'.format(mapfname, e)) print('could not open {0}: {1}'.format(mapfname, e))
except ValueError as e: except ValueError as e:
@ -61,7 +61,7 @@ except ValueError as e:
sys.exit(3) sys.exit(3)
# copy the files to the correct locations # copy the files to the correct locations
for crc, path in crcmap.items(): for (crc, path) in crcmap:
if not (crc in texmap): if not (crc in texmap):
print('unmatched CRC: {0} ({1})'.format(crc, path)) print('unmatched CRC: {0} ({1})'.format(crc, path))
else: else: