1 15 16 package org.python.modules; 17 18 import java.util.*; 19 import org.python.core.*; 20 import org.python.modules.sre.*; 21 22 23 public class _sre { 24 public static int MAGIC = 20010701; 26 27 28 public static PatternObject compile(PyString pattern, int flags, 29 PyObject code, int groups, 30 PyObject groupindex, 31 PyObject indexgroup) { 32 char[] ccode = null; 33 if (code instanceof PyList) { 34 int n = code.__len__(); 35 ccode = new char[n]; 36 for (int i = 0; i < n; i++) 37 ccode[i] = (char) ((PyInteger)code.__getitem__(i).__int__()).getValue(); 38 } else { 39 throw Py.TypeError("Expected list"); 40 } 41 42 PatternObject po = new PatternObject(pattern, 43 flags, 44 ccode, 45 groups, 46 groupindex, 47 indexgroup); 48 return po; 49 } 50 51 52 53 public static int getcodesize() { 54 return 2; 55 } 56 57 58 public static int getlower(int ch, int flags) { 59 return SRE_STATE.getlower(ch, flags); 60 } 61 } 62 | Popular Tags |