[PATCH] Add Q'n'D Python script to find obsolete Java files

Wald Commits scm-commit at wald.intevation.org
Thu Sep 4 16:25:19 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1409840706 -7200
# Node ID adbf980004c00a4e53d24717f09c89db1e4e2dbf
# Parent  0a70cf74e58d62231e9b52e7d0fd2f1c6e0d66b6
Add Q'n'D Python script to find obsolete Java files.

diff -r 0a70cf74e58d -r adbf980004c0 artifacts/contrib/find-obsolete-java-files.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/contrib/find-obsolete-java-files.py	Thu Sep 04 16:25:06 2014 +0200
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import os
+
+def main():
+    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 i in range(len(cnames)):
+        x = cnames[i]
+        cname = x[0]
+        if cname == '':
+            continue
+        found = False
+        for j in range(len(cnames)):
+            if i == j:
+                continue
+            if cnames[j][1].find(cname) >= 0:
+                found = True
+                break
+        if not found:
+            print cname, x[2]
+
+
+if __name__ == "__main__":
+    main()


More information about the Dive4Elements-commits mailing list