comparison artifacts/contrib/find-obsolete-i18n-strings.py @ 7957:26971f97105f

Added script to find unused i18n in *.java and *.xml files.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 19 Jun 2014 18:20:39 +0200
parents
children
comparison
equal deleted inserted replaced
7956:ed37ba051103 7957:26971f97105f
1 #!/usr/bin/env python
2
3 import os
4 import re
5 import sys
6
7 KEY_RE = re.compile(r"^\s*([^\s=]+)\s*=.*$")
8
9 def main():
10 content = []
11 for root, dirs, files in os.walk('.'):
12 for f in files:
13 if not (f.endswith(".java") or f.endswith(".xml")):
14 continue
15 p = os.path.join(root, f)
16 with open(p, "rb") as jf:
17 content.append(jf.read())
18
19 content = ''.join(content)
20
21 for arg in sys.argv[1:]:
22 with open(arg, "rb") as prop:
23 for line in prop:
24 m = KEY_RE.match(line)
25 if not m:
26 continue
27 key = m.group(1)
28 if content.find(key) == -1:
29 print key
30
31 if __name__ == "__main__":
32 main()

http://dive4elements.wald.intevation.org