Author: jpages Date: 2012-04-27 15:58:29 +0200 (Fri, 27 Apr 2012) New Revision: 650 Url: http://nuiton.org/repositories/revision/jrst/650 Log: Le script python appelant docutils a ?\195?\169t?\195?\169 modifi?\195?\169. Mainetant les tests de g?\195?\169n?\195?\169ration du xml et de l'html fonctionnent. Modified: branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java Modified: branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py =================================================================== --- branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-04-26 16:29:18 UTC (rev 649) +++ branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-04-27 13:58:29 UTC (rev 650) @@ -2,51 +2,37 @@ # coding=utf-8 import __builtin__, os, sys, string -import java.io.File +from java.io import File, InputStream +from java.net import URL, JarURLConnection +from java.util.zip import ZipFile - -incompleteDictionary = False -try: - __builtin__.__dict__["openlegacy"] -except: - incompleteDictionary = True - -print "a faire : %s" % incompleteDictionary - # Save the path of __run__.py pathname = os.path.abspath(os.path.dirname(sys.argv[0])) # Add the lib path to sys.path -print sys.argv lib_path = os.path.dirname(sys.argv[1]) sys.path.append(lib_path) -# if it has not already been defined, the function jaropen will be able to -# read into the jar. -if incompleteDictionary: - print __builtin__ - print __builtin__.__dict__["open"] +# Check if the new open function doesn't exist +if "openlegacy" not in __builtin__.__dict__: + # Define the function jaropen which will be able to read into the jar. def jaropen(jarpath, mode, bufsize=-1): if "__pyclasspath__" in jarpath: - print "lib_path : " + lib_path - jarpath = string.replace(jarpath, '__pyclasspath__', lib_path+"!") - print "Jaropen: " + jarpath + " " + mode - if ("jar!" in jarpath): - f = File(jarpath) - istream = f.toURI().toURL().openStream(); + filepath = "jar:file:" + lib_path + "!" + jarpath = string.replace(jarpath, "__pyclasspath__", filepath) + url = URL(jarpath) + inStream = url.openStream() f = __builtin__.openlegacy(inStream, bufsize) else: f = __builtin__.openlegacy(jarpath, mode, bufsize) return f + # Replace in the dictionnary the old open function by the new one __builtin__.__dict__["openlegacy"] = __builtin__.__dict__["open"] __builtin__.__dict__["open"] = jaropen -else: - print "Else : Deja fait !" # Add the lib path to sys.path -print sys.argv lib_path = os.path.dirname(sys.argv[1]) sys.path.append(lib_path) @@ -59,13 +45,14 @@ filein = sys.argv[3] fileout = sys.argv[4] - # If Docutils can manage this output format, we call it from docutils.core import publish_file, default_description listType = ["xml", "html", "odt", "latex", "man", "s5", "xetex"] if typeOutput in listType: - print publish_file( source_path=filein, destination_path=fileout, - writer_name=typeOutput.lower() ) + if typeOutput == "man": + typeOutput = "manpage" + publish_file( source_path=filein, destination_path=fileout, + writer_name=typeOutput ) else: print "Wrong output format" Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java =================================================================== --- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-04-26 16:29:18 UTC (rev 649) +++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-04-27 13:58:29 UTC (rev 650) @@ -136,7 +136,6 @@ JRST.generate(JRST.Format.HTML.name(), in, out, JRST.Overwrite.ALLTIME); } - @Test public void generateOdt() throws Exception {