Hi,
I'm struggling with refactoring old stax xml/python code. The one issue
that keeps coming up is when to interleave python in job files and when to
have python routines called externally.
For example,we have a lot of STAX code written like this one (below). It
seems that all of this kind of work could be done in a pure python function
in a utility file somewhere.
Make sense?
-T
Example function:
<function name="createOutputFile">
<function-prolog>
</function-prolog>
<function-no-args/>
<sequence>
<script>
currentContext =
gCurrentRootScriptContextMgr.getCurrentScriptContext()
scriptFileName = currentContext.scrScriptFileName
import os
(filePath, fileName) = os.path.split(scriptFileName)
outFilePath = "Output"
outFileName = "out." + fileName
</script>
<call function="'logSTAXMsgAlways'">"StaxScriptXml-58: Script
File Name is %s" % scriptFileNa
<if expr="filePath != None">
<sequence>
<script>
os.path.normpath(filePath)
outFilePath = os.path.join(filePath, outFilePath)
</script>
<if expr="os.path.isdir(outFilePath)">
<call function="'logSTAXMsgVerbose'">"Output
directory exists"</call>
<else>
<sequence>
<call function="'logSTAXMsgVerbose'">"Creating
Output Directory"</call>
<script>
os.mkdir(outFilePath)
</script>
</sequence>
</else>
</if>
</sequence>
</if>
<script>
outFileName = os.path.join(outFilePath, outFileName)
currentScriptContext.openOutputHandle(outFileName)
</script>
</sequence>
</function>
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users