cleanup: Remove vo_vesa/vo_fbdev remains
[mplayer.git] / TOOLS / mphelp_check.py
blobca4bb02ccb2f197c8730196294d32b3266da5fcf
1 #!/usr/bin/python
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
9 import sys
10 import re
12 def parse(filename):
13 r = {}
14 f = open(filename)
15 it = iter(f)
16 cur = ''
17 for line in it:
18 line = line.strip()
19 if not line.startswith('#define'):
20 while line and line[-1] == '\\':
21 line = it.next().strip()
22 continue
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('"')
28 r[name] = value
29 f.close()
30 return r
32 def compare(base, other, show_missing=False):
33 r = re.compile('%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%]')
34 missing = []
35 for key in base:
36 if key not in other:
37 missing.append(key)
38 continue
39 if re.findall(r, base[key]) != re.findall(r, other[key]):
40 print 'Mismatch: ', key
41 print base[key]
42 print other[key]
43 print
44 del other[key]
45 if other:
46 extra = other.keys()
47 extra.sort()
48 print 'Extra: ', ' '.join(extra)
49 if show_missing and missing:
50 missing.sort()
51 print 'Missing: ', ' '.join(missing)
53 if len(sys.argv) < 3:
54 print 'Usage:\n'+sys.argv[0]+' [--missing] base_helpfile otherfile1 '\
55 '[otherfile2 ...]'
56 sys.exit(1)
57 i = 1
58 show_missing = False
59 if sys.argv[i] in ( '--missing', '-missing' ):
60 show_missing = True
61 i = 2
62 base = parse(sys.argv[i])
63 for filename in sys.argv[i+1:]:
64 print '*****', filename
65 compare(base, parse(filename), show_missing)
66 print '\n'