Mercurial > dive4elements > river
comparison artifacts/contrib/check-i18n-properties.py @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/contrib/check-i18n-properties.py@daf413420cf7 |
children |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
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() |