[kepler-users] Jython Actor and Regex
Sean Riddle
swriddle at gmail.com
Tue Apr 6 14:54:57 PDT 2010
I think the problem is that you're trying to send the re match object,
rather than the matched subgroup. Try
self.output.broadcast(num.group(1)) instead.
- Sean
On Apr 6, 2010, at 2:51 PM, Jim Amrhein wrote:
> Hi Gang,
> I'm trying to convert/use the following python script in a Jython
> Actor.
> The original script :
>
> #!/usr/bin/python
> import re
> input = "<output type=\"netCDF\">/tmp/DEV/G4wa/MOD04_L2.005_4899.nc</
> output>"
> num = re.search('>([^<>]*?)<\/', input, re.M|re.I)
> if num:
> print num.group(1);
>
> All the script does is outputs the xml contents from a string like
> <tag>contents</tag>:
>
> Here's the Jython actor's version :
>
> import re
>
> # This is a simple actor outputs the xml contents if any is found.
> class Main :
> "Copy the inputs to the output."
> def fire(self) :
> token = self.input.get(0)
> num = re.search('>([^<>]*?)<\/', input, re.M|re.I)
> self.output.broadcast(num)
> return
>
> But, I'm getting the error:
>
>
> File "<string>", line 9, in fire
> File "/g3sandbox/jamrhein/Kepler-2.0-RC1/core-2.0/lib/jar/jython.jar/
> Lib/sre.py", line 137, in search
> File "/g3sandbox/jamrhein/Kepler-2.0-RC1/core-2.0/lib/jar/jython.jar/
> Lib/sre.py", line 227, in _compile
> File "/g3sandbox/jamrhein/Kepler-2.0-RC1/core-2.0/lib/jar/jython.jar/
> Lib/sre_compile.py", line 437, in compile
> File "/g3sandbox/jamrhein/Kepler-2.0-RC1/core-2.0/lib/jar/jython.jar/
> Lib/sre_compile.py", line 421, in _code
> File "/g3sandbox/jamrhein/Kepler-2.0-RC1/core-2.0/lib/jar/jython.jar/
> Lib/sre_compile.py", line 143, in _compile
> ValueError: ('unsupported operand type', 'subpattern')
>
> The original code runs in python and jython, so one question is: How
> different is the Jython actor from jython? Any suggestions?
>
>
>
> Thanks,
> JSA
> _______________________________________________
> Kepler-users mailing list
> Kepler-users at kepler-project.org
> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
More information about the Kepler-users
mailing list