[jboss-svn-commits] JBL Code SVN: r36190 - in labs/jbossrules/trunk/src/script: deprecated and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Dec 3 05:49:57 EST 2010


Author: ge0ffrey
Date: 2010-12-03 05:49:57 -0500 (Fri, 03 Dec 2010)
New Revision: 36190

Added:
   labs/jbossrules/trunk/src/script/deprecated/
   labs/jbossrules/trunk/src/script/deprecated/docbot-masseur.py
   labs/jbossrules/trunk/src/script/deprecated/gwt/
   labs/jbossrules/trunk/src/script/deprecated/image_usage.rb
   labs/jbossrules/trunk/src/script/deprecated/style_usage.rb
Log:
gather all dev scripts together under src/script. Prepended with deprecated because there is serious doubt that they are still in use. Pls move a script outside the deprecated dir if you use it.

Copied: labs/jbossrules/trunk/src/script/deprecated/docbot-masseur.py (from rev 36169, labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py)
===================================================================
--- labs/jbossrules/trunk/src/script/deprecated/docbot-masseur.py	                        (rev 0)
+++ labs/jbossrules/trunk/src/script/deprecated/docbot-masseur.py	2010-12-03 10:49:57 UTC (rev 36190)
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+
+#
+# This script will flatten out a folder based docbook manual into a docbot friendly "flat" structure
+# (and update links in files accordingly)
+# Author: Michael Neale
+#
+
+import os, sys, shutil
+
+def flatten(root, output) :  
+    if not os.path.isdir(output):
+        os.mkdir(output)
+    if not os.path.isdir(os.path.join(output, "images")):
+        os.mkdir(os.path.join(output, "images"))
+    sections = {}   
+    top_files = []
+    names = os.listdir(root)
+    for name in names:
+        if os.path.isdir(os.path.join(root, name)) :
+            if not name == ".svn":
+                flattenDir(root, name, output, sections)
+        else:
+            if name.endswith(".xml") :
+                top_files.append(name)
+            elif name != ".svn":
+                shutil.copyfile(os.path.join(root, name), os.path.join(output, name))
+    for file in top_files:        
+        contents = open(os.path.join(root, file), "r").read()
+        for section in sections:
+            contents = contents.replace(section, sections[section])
+        outfile = open(os.path.join(output, file), "w")
+        outfile.write(contents)
+        
+                    
+            
+            
+
+
+def flattenDir(root, dir, output, sections):
+    docs = []
+    images = []
+    names = os.listdir(os.path.join(root, dir))
+    for name in names:
+        if name.endswith(".xml"):
+            docs.append(name)
+        else:
+            if name != ".svn":
+                images.append(name)
+                shutil.copyfile(os.path.join(root, dir, name), os.path.join(output, "images", dir + "_" + name))
+    for doc in docs: 
+        new_name = dir + "_" + doc
+        sections[dir + "/" + doc] = new_name
+        file = open(os.path.join(root, dir, doc), "r").read()
+        outfile = open(os.path.join(output, new_name), "w")
+        for img in images:
+            file = file.replace(img, "images/" + dir + "_" + img)
+        outfile.write(file)
+
+        
+
+
+if len(sys.argv) < 2:
+    print "2 arguments required: <path to root of documentation> <output path>. eg: docbot-masseur.py ./something ./output"
+else:
+    flatten(sys.argv[1], sys.argv[2])
+    


Property changes on: labs/jbossrules/trunk/src/script/deprecated/docbot-masseur.py
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossrules/trunk/src/script/deprecated/gwt (from rev 36169, labs/jbossrules/trunk/lib/utility-scripts/gwt)

Copied: labs/jbossrules/trunk/src/script/deprecated/image_usage.rb (from rev 36169, labs/jbossrules/trunk/lib/utility-scripts/image_usage.rb)
===================================================================
--- labs/jbossrules/trunk/src/script/deprecated/image_usage.rb	                        (rev 0)
+++ labs/jbossrules/trunk/src/script/deprecated/image_usage.rb	2010-12-03 10:49:57 UTC (rev 36190)
@@ -0,0 +1,44 @@
+#
+# This looks for unused images in GWT code. 
+# Gets a list of images, and looks to find if they are used. 
+#
+# Author: Michael Neale
+#
+
+#directory recursive processor...
+def mapdir(dir, predicate, action) 
+    Dir.foreach(dir) do |d| 
+      if d != "." && d != ".." then
+        sub = "#{dir}/#{d}"        
+        if not File.directory? sub and predicate.call(sub) then
+          action.call(sub)
+        else 
+          if File.directory? sub and not sub.include? ".svn" 
+	  then mapdir(sub, predicate, action) end
+        end        
+      end
+    end
+end
+
+
+def process(image_root, sources_root)
+  images = []
+  mapdir image_root, lambda { |f| true }, lambda { |f| images << f }
+
+  mapdir sources_root, lambda { |f| f.include? ".java" or f.include? ".html" or f.include? ".js" }, 
+   lambda do |f|
+    contents = IO.read(f)
+    images.each do |img|
+      if contents.include? img.split("/images/")[1] then
+         images = images - [img]
+      end
+    end 
+   end
+         
+  puts "#{images.size} Unused images: \n " 
+  puts images
+
+
+end
+
+process "/Users/michaelneale/project/jboss-rules/drools-guvnor/src/main/java/org/drools/brms/public/images", "/Users/michaelneale/project/jboss-rules/drools-guvnor/src/main/java/org/drools/brms"


Property changes on: labs/jbossrules/trunk/src/script/deprecated/image_usage.rb
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossrules/trunk/src/script/deprecated/style_usage.rb (from rev 36169, labs/jbossrules/trunk/lib/utility-scripts/style_usage.rb)
===================================================================
--- labs/jbossrules/trunk/src/script/deprecated/style_usage.rb	                        (rev 0)
+++ labs/jbossrules/trunk/src/script/deprecated/style_usage.rb	2010-12-03 10:49:57 UTC (rev 36190)
@@ -0,0 +1,47 @@
+# This looks for unused styles in GWT code. 
+# Gets a list of images, and looks to find if they are used. 
+#
+# Author: Michael Neale
+#
+
+#directory recursive processor...
+def mapdir(dir, predicate, action) 
+    Dir.foreach(dir) do |d| 
+      if d != "." && d != ".." then
+        sub = "#{dir}/#{d}"        
+        if not File.directory? sub and predicate.call(sub) then
+          action.call(sub)
+        else 
+          if File.directory? sub and not sub.include? ".svn" 
+	  then mapdir(sub, predicate, action) end
+        end        
+      end
+    end
+end
+
+
+def process(css, sources_root) 
+  style_names = []
+  IO.foreach(css) do |line|
+    #rip the name from the line if is starts with "."
+    if line.slice(0, 1) == "." then
+      puts "Line is: " + line
+      style_names << line.slice(1, line.index(' ') - 1)
+    end
+  end
+
+  mapdir sources_root, lambda {  |f| f.include? ".java" or f.include? ".html" or f.include? ".js" }, 
+    lambda do |f|
+      contents = IO.read(f)
+      style_names.each do |style|
+       if contents.include? '"' + style + '"' then
+         style_names = style_names - [style]
+       end
+      end
+    end
+
+  puts "#{style_names.size} unused styles : "
+  puts style_names
+end
+
+process "/Users/michaelneale/project/jboss-rules/drools-guvnor/src/main/java/org/drools/brms/public/JBRMS.css", "/Users/michaelneale/project/jboss-rules/drools-guvnor/src/main/java/org/drools/brms"


Property changes on: labs/jbossrules/trunk/src/script/deprecated/style_usage.rb
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the jboss-svn-commits mailing list