Package org.python.core

Examples of org.python.core.PyDictionary


                if (maxRows != Py.None) {
                    stmt.setMaxRows(maxRows.asInt());
                }

                // get the bindings per the stored proc spec
                PyDictionary callableBindings = new PyDictionary();

                procedure.normalizeInput(params, callableBindings);

                // overwrite with any user specific bindings
                if (bindings instanceof PyDictionary) {
                    callableBindings.update(bindings);
                }

                this.statement = new PyStatement(stmt, procedure);

                this.execute(params, callableBindings);
View Full Code Here


    /**
     * Motivated by a NPE reported on http://bugs.jython.org/issue1174.
     */
    public void testBasicEval() throws Exception {
        PyDictionary test = new PyDictionary();
        test.__setitem__(new PyUnicode("one"), new PyUnicode("two"));
        PythonInterpreter.initialize(System.getProperties(), null, new String[] {});
        PythonInterpreter interp = new PythonInterpreter();
        PyObject pyo = interp.eval("{u'one': u'two'}");
        assertEquals(test, pyo);
    }
View Full Code Here

            zipFile = new ZipFile(file);
        } catch (IOException ioe) {
            throw zipimport.ZipImportError(String.format("can't read Zip file: '%s'", archive));
        }

        PyObject files = new PyDictionary();
        try {
            readZipFile(zipFile, files);
        } finally {
            try {
                zipFile.close();
View Full Code Here

                for (int i = 0; i < n; i++) {
                    write_object(list.__getitem__(i), depth + 1);
                }
            } else if (v instanceof PyDictionary) {
                write_byte(TYPE_DICT);
                PyDictionary dict = (PyDictionary) v;
                for (PyObject item : dict.iteritems().asIterable()) {
                    PyTuple pair = (PyTuple) item;
                    write_object(pair.__getitem__(0), depth + 1);
                    write_object(pair.__getitem__(1), depth + 1);
                }
                write_object(null, depth + 1);
View Full Code Here

    /**
     * Initialize the environ dict from System.getenv. environ may be empty when the
     * security policy doesn't grant us access.
     */
    private static PyObject getEnviron() {
        PyObject environ = new PyDictionary();
        Map<String, String> env;
        try {
            env = System.getenv();
        } catch (SecurityException se) {
            return environ;
        }
        for (Map.Entry<String, String> entry : env.entrySet()) {
            environ.__setitem__(Py.newString(entry.getKey()), Py.newString(entry.getValue()));
        }
        return environ;
    }
View Full Code Here

            if (count2 > 0xFF || count3 > 0xFF) {
                needDict = true;
            }

            if (needDict) {
                PyObject result = new PyDictionary();
                for (i = 0; i < 256; i++) {
                    result.__setitem__(Py.newInteger(decode.charAt(i)), Py.newInteger(i));
                }
                return result;
            }

            // Create a three-level trie
View Full Code Here

                    }
                    return new PyList(items);
                }

                case TYPE_DICT: {
                    PyDictionary d = new PyDictionary();
                    while (true) {
                        PyObject key = read_object(depth + 1);
                        if (key == null) {
                            break;
                        }
                        PyObject value = read_object(depth + 1);
                        if (value != null) {
                            d.__setitem__(key, value);
                        }
                    }
                    return d;
                }
View Full Code Here

    public PyObject groupdict(PyObject[] args, String[] kws) {
        ArgParser ap = new ArgParser("groupdict", args, kws, "default");
        PyObject def = ap.getPyObject(0, Py.None);

        PyObject result = new PyDictionary();

        if (pattern.groupindex == null)
            return result;

        PyObject keys = pattern.groupindex.invoke("keys");

        PyObject key;
        for (int i = 0; (key = keys.__finditem__(i)) != null; i++) {
            PyObject item = getslice(key, def);
            result.__setitem__(key, item);
        }
        return result;
    }
View Full Code Here

    public PyLocal(PyType subType) {
        super(subType);
        // Don't lazy load the underlying dict in the instantiating thread; that would
        // call __init__ a the second time
        tdict.set(new PyDictionary());
    }
View Full Code Here

        super.setDict(dict);
    }

    @Override
    public PyObject fastGetDict() {
        PyDictionary ldict = tdict.get();
        if (ldict == null) {
            ldict = new PyDictionary();
            tdict.set(ldict);
            dispatch__init__(args, keywords);
        }
        return ldict;
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyDictionary

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.