annotate artifacts/contrib/check-i18n-properties.py @ 8716:b5ac17a10d22

(issue1754) Only create new Recommendations I belive that this was the original intent of this function otherwise why create a list of newRecommendations at all if we always recreate all Recommendations again. With the side effect that old recommendations had no master artifact the created artifacts of already existing artifacts did not have enough information to live and were not shown in the client so this problem was hidden.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 27 Apr 2015 11:45:31 +0200
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()

http://dive4elements.wald.intevation.org