mirror of
https://github.com/holub/mame
synced 2025-05-16 19:00:43 +03:00
Create handy ROM filename discrepancy spotter
This commit is contained in:
parent
677aaaec3d
commit
aeffa61e35
53
src/tools/discrepancy-fixer.py
Executable file
53
src/tools/discrepancy-fixer.py
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Fix discrepancies in arcade ROM dump names, by Zoe Blade
|
||||
# For Python 2
|
||||
|
||||
import xml.etree.ElementTree
|
||||
|
||||
print('Loading XML file...')
|
||||
root = xml.etree.ElementTree.parse('arcade.xml').getroot()
|
||||
print('Done.')
|
||||
|
||||
for childMachine in root.iter('machine'):
|
||||
if not childMachine.get('cloneof'):
|
||||
continue
|
||||
|
||||
for parentMachine in root.iter('machine'):
|
||||
if not parentMachine.get('name') == childMachine.get('cloneof'):
|
||||
continue
|
||||
|
||||
# Machine pair found
|
||||
|
||||
for childRom in childMachine.iter('rom'):
|
||||
for parentRom in parentMachine.iter('rom'):
|
||||
if not parentRom.get('sha1') == childRom.get('sha1'):
|
||||
continue
|
||||
|
||||
# ROM pair found
|
||||
|
||||
if parentRom.get('name') == childRom.get('name'):
|
||||
break
|
||||
|
||||
# The names don't match
|
||||
|
||||
sourceFilename = childMachine.get('sourcefile')
|
||||
|
||||
input = open(sourceFilename, 'r')
|
||||
source = input.read()
|
||||
input.close()
|
||||
|
||||
oldRomFilename = '"' + childRom.get('name') + '"'
|
||||
newRomFilename = '"' + parentRom.get('name') + '"'
|
||||
|
||||
oldRomFilenamePadded = oldRomFilename.ljust(14, ' ')
|
||||
newRomFilenamePadded = newRomFilename.ljust(14, ' ')
|
||||
|
||||
source = source.replace(oldRomFilenamePadded, newRomFilenamePadded) # Try to preserve fancy spacing where possible
|
||||
source = source.replace(oldRomFilename, newRomFilename) # Fallback on just replacing the filename
|
||||
|
||||
output = open(sourceFilename, 'w')
|
||||
output.write(source)
|
||||
output.close()
|
||||
|
||||
print(sourceFilename + ': ' + oldRomFilename + ' -> ' + newRomFilename)
|
34
src/tools/discrepancy-spotter.py
Executable file
34
src/tools/discrepancy-spotter.py
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Find discrepancies in arcade ROM dump names, by Zoe Blade
|
||||
# For Python 2
|
||||
|
||||
import xml.etree.ElementTree
|
||||
|
||||
print('Loading XML file...')
|
||||
root = xml.etree.ElementTree.parse('arcade.xml').getroot()
|
||||
print('Done.')
|
||||
|
||||
for childMachine in root.iter('machine'):
|
||||
if not childMachine.get('cloneof'):
|
||||
continue
|
||||
|
||||
for parentMachine in root.iter('machine'):
|
||||
if not parentMachine.get('name') == childMachine.get('cloneof'):
|
||||
continue
|
||||
|
||||
# Machine pair found
|
||||
|
||||
for childRom in childMachine.iter('rom'):
|
||||
for parentRom in parentMachine.iter('rom'):
|
||||
if not parentRom.get('sha1') == childRom.get('sha1'):
|
||||
continue
|
||||
|
||||
# ROM pair found
|
||||
|
||||
if parentRom.get('name') == childRom.get('name'):
|
||||
break
|
||||
|
||||
# The names don't match
|
||||
|
||||
print(childMachine.get('sourcefile') + ' ' + childMachine.get('name') + ': ' + childRom.get('name') + ' -> ' + parentRom.get('name'))
|
Loading…
Reference in New Issue
Block a user