Mercurial > dive4elements > river
comparison flys-artifacts/contrib/check-i18n-properties.py @ 3651:06a65baae494
merged flys-artifacts/2.9
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:43 +0200 |
parents | daf413420cf7 |
children |
comparison
equal
deleted
inserted
replaced
3549:6a8f83c538e3 | 3651:06a65baae494 |
---|---|
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() |