comparison artifacts/contrib/find-obsolete-java-files.py @ 8192:adbf980004c0

Add Q'n'D Python script to find obsolete Java files.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 04 Sep 2014 16:25:06 +0200
parents
children f799db6b1219
comparison
equal deleted inserted replaced
8191:0a70cf74e58d 8192:adbf980004c0
1 #!/usr/bin/env python
2
3 import os
4
5 def main():
6 cnames = []
7 for root, _, files in os.walk('.'):
8 for f in files:
9 if not (f.endswith(".java") or f.endswith('.xml')):
10 continue
11 p = os.path.join(root, f)
12 with open(p, "rb") as jf:
13 content = jf.read()
14 if f.endswith('.xml'):
15 cnames.append(('', content, p))
16 else:
17 cname = f[0:-5]
18 cnames.append((cname, content, p))
19
20 for i in range(len(cnames)):
21 x = cnames[i]
22 cname = x[0]
23 if cname == '':
24 continue
25 found = False
26 for j in range(len(cnames)):
27 if i == j:
28 continue
29 if cnames[j][1].find(cname) >= 0:
30 found = True
31 break
32 if not found:
33 print cname, x[2]
34
35
36 if __name__ == "__main__":
37 main()

http://dive4elements.wald.intevation.org