[jboss-svn-commits] JBL Code SVN: r18287 - labs/jbossrules/trunk/lib/utility-scripts.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Feb 3 23:38:57 EST 2008
Author: michael.neale at jboss.com
Date: 2008-02-03 23:38:57 -0500 (Sun, 03 Feb 2008)
New Revision: 18287
Added:
labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py
Log:
documentation script for product team - so they can use out hierarchical structure in docbot and other tools
Added: labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py
===================================================================
--- labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py (rev 0)
+++ labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py 2008-02-04 04:38:57 UTC (rev 18287)
@@ -0,0 +1,55 @@
+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)
+ 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 not 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)
+
+
+
+
+
+flatten(sys.argv[1], sys.argv[2])
+
Property changes on: labs/jbossrules/trunk/lib/utility-scripts/docbot-masseur.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list