Mercurial > dive4elements > river
annotate artifacts/contrib/check-i18n-properties.py @ 8587:07c9ac22f611
(issue1755) Generalise BedQuality result handling
The bedquality calculation now produces a result for each time period
which has BedQualityResultValues for each specific result type.
Formally this was split up in density, porosity and diameter classes
with some bedload diameter classes mixed in for extra fun.
The intent of this commit is to allow more shared code and generic
access patterns to the BedQuality results.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 18 Mar 2015 18:42:08 +0100 |
parents | 5aa05a7a34b7 |
children |
rev | line source |
---|---|
2625
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import sys |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import re |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 SPLIT_RE = re.compile(r"^\s*([^=]+)=\s*(.*)\s*") |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 def load_properties_file(filename): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 props = {} |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 with open(filename, "r") as f: |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 while True: |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 line = f.readline() |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 if not line: break |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 m = SPLIT_RE.match(line) |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 if not m: continue |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 k = m.group(1).strip() |
2627
daf413420cf7
check-i18n-properties.py: Checked in unsaved version.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2625
diff
changeset
|
17 v = m.group(2).strip() |
2625
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 if k in props: |
2627
daf413420cf7
check-i18n-properties.py: Checked in unsaved version.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2625
diff
changeset
|
19 print >> sys.stderr, "'%s' found more than once in '%s'." % ( |
2625
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 k, filename) |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 else: |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 props[k] = v |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 return props |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 def main(): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 props = [(arg, load_properties_file(arg)) for arg in sys.argv[1:]] |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 l = len(props) |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 for i in range(0, l): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 a = props[i][1] |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 for j in range(i+1, l): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 b = props[j][1] |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 for k in a.iterkeys(): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 if k not in b: |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 print >> sys.stderr, "'%s' found in '%s' but not in '%s'." % ( |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 k, props[i][0], props[j][0]) |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 for k in b.iterkeys(): |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 if k not in a: |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 print >> sys.stderr, "'%s' found in '%s' but not in '%s'." % ( |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 k, props[j][0], props[i][0]) |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 if __name__ == '__main__': |
72ce02d1a568
Added consistency checker for i18n properties files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 main() |