3 # Tool to compare MPlayer translation files against a base file. Reports
4 # conflicting arguments, extra strings not present in the base file and
5 # (optionally) missing strings.
7 # Written by Uoti Urpala
19 if not line
.startswith('#define'):
20 while line
and line
[-1] == '\\':
21 line
= it
.next().strip()
23 _
, name
, value
= line
.split(None, 2)
24 value
= value
.strip('"')
25 while line
[-1] == '\\':
26 line
= it
.next().strip()
27 value
+= line
.rstrip('\\').strip('"')
32 def compare(base
, other
, show_missing
=False):
33 r
= re
.compile('%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%]')
39 if re
.findall(r
, base
[key
]) != re
.findall(r
, other
[key
]):
40 print 'Mismatch: ', key
48 print 'Extra: ', ' '.join(extra
)
49 if show_missing
and missing
:
51 print 'Missing: ', ' '.join(missing
)
54 print 'Usage:\n'+sys
.argv
[0]+' [--missing] base_helpfile otherfile1 '\
59 if sys
.argv
[i
] in ( '--missing', '-missing' ):
62 base
= parse(sys
.argv
[i
])
63 for filename
in sys
.argv
[i
+1:]:
64 print '*****', filename
65 compare(base
, parse(filename
), show_missing
)