Subversion Repositories SmartDukaan

Rev

Rev 63 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.util;

import java.util.List;

import org.python.core.PyList;
import org.python.core.PyObject;
import org.python.util.PythonInterpreter;

/**
 * @author naveen
 *
 */
public class JythonWrapper {
        
        /**
         * Jython source path
         */
        public static String JYTHON_SRC_PATH = "src/jython/";
        
        /**
         * Private Python interpreter instance
         */
        private PythonInterpreter py = null;
        
        /**
         * Executes Jython script given absolute path
         * 
         * @param filename
         */
        public void exec(String filename) {
                if(this.py == null) {
                        this.py = new PythonInterpreter();
                }
                
                this.py.execfile(filename);
        }
        
        /**
         * 
         * @return
         */
        @SuppressWarnings("unchecked")
        public List getValues() {
                PyObject values = this.py.get("values");
                
                return (PyList)values;
        }
}