comparison artifacts/contrib/check-i18n-properties.py @ 7730:e1b831fe435a slt-simplify-cross-sections

Merged default into slt-simplify-cross-sections branch and updated package and class names.
author Tom Gottfried <tom@intevation.de>
date Mon, 20 Jan 2014 14:04:20 +0100
parents 5aa05a7a34b7
children
comparison
equal deleted inserted replaced
5084:ca45dd039b54 7730:e1b831fe435a
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