comparison flys-artifacts/contrib/check-i18n-properties.py @ 3786:4adc35aa655c

merged flys-artifacts/2.9.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:47 +0200
parents daf413420cf7
children
comparison
equal deleted inserted replaced
3719:e82acd5c86f7 3786:4adc35aa655c
1 #!/usr/bin/env python
2
3 import sys
4 import re
5
6 SPLIT_RE = re.compile(r"^\s*([^=]+)=\s*(.*)\s*")
7
8 def load_properties_file(filename):
9 props = {}
10 with open(filename, "r") as f:
11 while True:
12 line = f.readline()
13 if not line: break
14 m = SPLIT_RE.match(line)
15 if not m: continue
16 k = m.group(1).strip()
17 v = m.group(2).strip()
18 if k in props:
19 print >> sys.stderr, "'%s' found more than once in '%s'." % (
20 k, filename)
21 else:
22 props[k] = v
23 return props
24
25 def main():
26
27 props = [(arg, load_properties_file(arg)) for arg in sys.argv[1:]]
28
29 l = len(props)
30
31 for i in range(0, l):
32 a = props[i][1]
33 for j in range(i+1, l):
34 b = props[j][1]
35 for k in a.iterkeys():
36 if k not in b:
37 print >> sys.stderr, "'%s' found in '%s' but not in '%s'." % (
38 k, props[i][0], props[j][0])
39 for k in b.iterkeys():
40 if k not in a:
41 print >> sys.stderr, "'%s' found in '%s' but not in '%s'." % (
42 k, props[j][0], props[i][0])
43
44 if __name__ == '__main__':
45 main()

http://dive4elements.wald.intevation.org