[PATCH] Find obsolete Java files in more than one project hierachie

Wald Commits scm-commit at wald.intevation.org
Fri Sep 5 10:10:47 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1409904642 -7200
# Node ID f799db6b1219d029004f4e2f9e81c3de6c168b42
# Parent  67b663ed049617dc768d1bd3445fa06d5f501678
Find obsolete Java files in more than one project hierachie.

diff -r 67b663ed0496 -r f799db6b1219 artifacts/contrib/find-obsolete-java-files.py
--- a/artifacts/contrib/find-obsolete-java-files.py	Fri Sep 05 10:09:16 2014 +0200
+++ b/artifacts/contrib/find-obsolete-java-files.py	Fri Sep 05 10:10:42 2014 +0200
@@ -1,21 +1,25 @@
 #!/usr/bin/env python
 
 import os
+import sys
 
 def main():
+    dirs = ['.'] if len(sys.argv) < 2 else sys.argv[1:]
+
     cnames = []
-    for root, _, files in os.walk('.'):
-        for f in files:
-            if not (f.endswith(".java") or f.endswith('.xml')):
-                continue
-            p = os.path.join(root, f)
-            with open(p, "rb") as jf:
-                content = jf.read()
-            if f.endswith('.xml'):
-                cnames.append(('', content, p))
-            else:
-                cname = f[0:-5]
-                cnames.append((cname, content, p))
+    for dir in dirs:
+        for root, _, files in os.walk(dir):
+            for f in files:
+                if not (f.endswith(".java") or f.endswith('.xml')):
+                    continue
+                p = os.path.join(root, f)
+                with open(p, "rb") as jf:
+                    content = jf.read()
+                if f.endswith('.xml'):
+                    cnames.append(('', content, p))
+                else:
+                    cname = f[0:-5]
+                    cnames.append((cname, content, p))
 
     for i in range(len(cnames)):
         x = cnames[i]


More information about the Dive4Elements-commits mailing list