Mercurial > dive4elements > river
comparison artifacts/contrib/find-obsolete-java-files.py @ 8196:f799db6b1219
Find obsolete Java files in more than one project hierachie.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 10:10:42 +0200 |
parents | adbf980004c0 |
children |
comparison
equal
deleted
inserted
replaced
8195:67b663ed0496 | 8196:f799db6b1219 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import os | 3 import os |
4 import sys | |
4 | 5 |
5 def main(): | 6 def main(): |
7 dirs = ['.'] if len(sys.argv) < 2 else sys.argv[1:] | |
8 | |
6 cnames = [] | 9 cnames = [] |
7 for root, _, files in os.walk('.'): | 10 for dir in dirs: |
8 for f in files: | 11 for root, _, files in os.walk(dir): |
9 if not (f.endswith(".java") or f.endswith('.xml')): | 12 for f in files: |
10 continue | 13 if not (f.endswith(".java") or f.endswith('.xml')): |
11 p = os.path.join(root, f) | 14 continue |
12 with open(p, "rb") as jf: | 15 p = os.path.join(root, f) |
13 content = jf.read() | 16 with open(p, "rb") as jf: |
14 if f.endswith('.xml'): | 17 content = jf.read() |
15 cnames.append(('', content, p)) | 18 if f.endswith('.xml'): |
16 else: | 19 cnames.append(('', content, p)) |
17 cname = f[0:-5] | 20 else: |
18 cnames.append((cname, content, p)) | 21 cname = f[0:-5] |
22 cnames.append((cname, content, p)) | |
19 | 23 |
20 for i in range(len(cnames)): | 24 for i in range(len(cnames)): |
21 x = cnames[i] | 25 x = cnames[i] |
22 cname = x[0] | 26 cname = x[0] |
23 if cname == '': | 27 if cname == '': |