Package org.python.core

Examples of org.python.core.PyString


        PyDictionary result = (PyDictionary)evalPythonString(output);
        return result.__finditem__(name);
    }

    public void doEnvVarTestCheckReturn(String name, String value) throws Exception {
        PyString envVar = (PyString)doEnvVarTest(name);
        assertTrue("Env var '" + name + "' != '" + value + "', == '" + envVar.toString() + "'",
                   envVar.toString().compareTo(value) == 0);
    }
View Full Code Here


     * Initializes the module.
     *
     * @param dict
     */
    public static void classDictInit(PyObject dict) {
        dict.__setitem__("apilevel", new PyString("2.0"));
        dict.__setitem__("threadsafety", new PyInteger(1));
        dict.__setitem__("paramstyle", new PyString("qmark"));
        dict.__setitem__("__version__", Py.newString("7290"));
        dict.__setitem__("Date", new zxJDBCFunc("Date", 1, 3, 3,
                                                "construct a Date from year, month, day"));
        dict.__setitem__("Time", new zxJDBCFunc("Time", 2, 3, 3,
                                                "construct a Date from hour, minute, second"));
View Full Code Here

        try {
            Class<?> c = Class.forName("java.sql.Types");
            Field[] fields = c.getFields();

            for (Field f : fields) {
                PyString name = Py.newString(f.getName());
                PyObject value = new DBApiType(f.getInt(c));
                dict.__setitem__(name, value);
                sqltype.__setitem__(value, name);
            }

            c = Class.forName("java.sql.ResultSet");
            fields = c.getFields();

            for (Field f : fields) {
                PyString name = Py.newString(f.getName());
                PyObject value = Py.newInteger(f.getInt(c));
                dict.__setitem__(name, value);
            }
        } catch (Throwable t) {
            throw makeException(t);
View Full Code Here

        bound.__call__();
        PyDataDescr desc = (PyDataDescr)tostringDesc.newInstance();
        desc.setType(simp.getType());
        assertEquals(doctoredSimple.getField("toStringVal").get(simp),
                     desc.__get__(simp, PyType.fromClass(doctoredSimple)).toString());
        assertEquals(desc.__getattr__("__doc__"), new PyString("tostring docs"));
    }
View Full Code Here

        if (pythonLibPath == null)
            return;
        File pythonLib = new File(pythonLibPath);
        if (!pythonLib.exists())
            return;
        systemState.path.append(new PyString(pythonLibPath));
        // Now check for .pth files in lib-python and process each one
        String[] libPythonContents = pythonLib.list();
        for (String libPythonContent : libPythonContents)
            if (libPythonContent.endsWith(PTH_FILE_EXTENSION))
                processPthFile(interp, systemState, pythonLibPath, libPythonContent);
View Full Code Here

                    interp.exec(line);
                    continue;
                }
                File archiveFile = new File(pythonLibPath, line);
                String archiveRealpath = archiveFile.getAbsolutePath();
                systemState.path.append(new PyString(archiveRealpath));
            }
        } catch (IOException iox) {
            System.err.println("IOException: " + iox.toString());
        }
    }
View Full Code Here

        ScriptEngine pythonEngine = manager.getEngineByName("python");
        Invocable invocableEngine = (Invocable) pythonEngine;

        assertNull(pythonEngine.eval("def f(x): return abs(x)"));
        assertEquals(Integer.valueOf(5), invocableEngine.invokeFunction("f", Integer.valueOf(-5)));
        assertEquals("spam", invocableEngine.invokeMethod(new PyString("  spam  "), "strip"));
        assertEquals("spam", invocableEngine.invokeMethod("  spam  ", "strip"));
    }
View Full Code Here

                throw Py.ValueError("unsupported pickle protocol: " + proto);
        }


        final private void load_persid() {
            load_persid(new PyString(file.readlineNoNl()));
        }
View Full Code Here

                    throw Py.ValueError("insecure string pickle " + i);
            }
            value = PyString.decode_UnicodeEscape(line, 1, n-1,
                                                  "strict", false);

            push(new PyString(value));
        }
View Full Code Here

        }


        final private void load_binstring() {
            int len = read_binint();
            push(new PyString(file.read(len)));
        }
View Full Code Here

TOP

Related Classes of org.python.core.PyString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.