[kepler-users] Jython Actor and Regex

Jim Amrhein James.S.Amrhein at nasa.gov
Tue Apr 6 14:51:24 PDT 2010


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



More information about the Kepler-users mailing list