commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r1041739 - /commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
Date Fri, 03 Dec 2010 09:14:29 GMT
Author: jbeard
Date: Fri Dec  3 09:14:29 2010
New Revision: 1041739

URL: http://svn.apache.org/viewvc?rev=1041739&view=rev
Log:
Refactored python frontend based on API change.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py?rev=1041739&r1=1041738&r2=1041739&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py Fri Dec
 3 09:14:29 2010
@@ -19,19 +19,26 @@ import sys
 import pkg_resources
 import getopt
 from lxml import etree
+import StringIO
 #import pdb
 
-def compile(pathsToSCXML=[],backend="state",options={}):
-	#open it
+#TODO: refactor this API
+def compile_from_path(pathsToSCXML=[],backend="state",options={}):
 	sourceDocuments = map(lambda p : etree.parse(p), pathsToSCXML)
+	return compile(sourceDocuments,backend,options)
 
+def compile_from_string(scxmlStrings=[],backend="state",options={}):
+	sourceDocuments = map(lambda p : etree.parse(StringIO.StringIO(p)), scxmlStrings)
+	return compile(sourceDocuments,backend,options)
+
+def compile(sourceDocuments,backend,options):
 	#do some transforms
 	if backend == "state":
 		from scxml.cgf.backends.js.StatePatternStatechartGenerator import config
 	elif backend == "table":
 		from scxml.cgf.backends.js.StateTableStatechartGenerator import config
 	elif backend == "switch":
-		from scxml.cgf.backends.js.SwitchyardGenerator import config
+		from scxml.cgf.backends.js.SwitchyardStatechartGenerator import config
 	else:
 		print "Backend not recognized!"
 
@@ -102,7 +109,7 @@ def main():
 	#print "opts: ", optlist
 	#print "args: ", args
 	opts = optlistToDict(optlist)
-	results = compile(args,opts["--backend"],opts) 
+	results = compile_from_path(args,opts["--backend"],opts) 
 
 	for result in results:
 		print result



Mime
View raw message