annotate artifacts/contrib/find-obsolete-java-files.py @ 8195:67b663ed0496

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

http://dive4elements.wald.intevation.org