Examples of PyList


Examples of org.python.core.PyList

    public PyObject fetchmany(int size) {
        if (results == null || results.size() == 0) {
            throw zxJDBC.makeException(zxJDBC.DatabaseError, "no results");
        }

        PyObject res = new PyList();
        PyObject current = results.get(0);

        if (size <= 0) {
            size = this.rowcount;
        }
View Full Code Here

Examples of org.python.core.PyList

        public PyObject readlines(long sizehint) {
            _complain_ifclosed();

            int sizehint_int = (int)sizehint;
            int total = 0;
            PyList lines = new PyList();
            PyString line = readline();
            while (line.__len__() > 0) {
                lines.append(line);
                total += line.__len__();
                if (0 < sizehint_int  && sizehint_int <= total)
                    break;
                line = readline();
            }
View Full Code Here

Examples of org.python.core.PyList

                case PY_COMPILED:
                    mod = load_compiled(name, filename.toString(), file);
                    break;
                case PKG_DIRECTORY:
                    PyModule m = org.python.core.imp.addModule(name);
                    m.__dict__.__setitem__("__path__", new PyList(new PyObject[] {filename}));
                    m.__dict__.__setitem__("__file__", filename);
                    ModuleInfo mi = findFromSource(name, filename.toString(), true, true);
                    type = mi.type;
                    file = mi.file;
                    filename = new PyString(mi.filename);
View Full Code Here

Examples of org.python.core.PyList

        modules.__setitem__(name.intern(), mod);
        return mod;
    }

    public static PyObject get_suffixes() {
        return new PyList(new PyObject[] {new PyTuple(new PyString(".py"),
                                                      new PyString("r"),
                                                      Py.newInteger(PY_SOURCE)),
                                          new PyTuple(new PyString("$py.class"),
                                                      new PyString("rb"),
                                                      Py.newInteger(PY_COMPILED)),});
View Full Code Here

Examples of org.python.core.PyList

                for (int i = 0; i < n; i++) {
                    write_object(t.__getitem__(i), depth + 1);
                }
            } else if (v instanceof PyList) {
                write_byte(TYPE_LIST);
                PyList list = (PyList) v;
                int n = list.__len__();
                write_int(n);
                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()) {
View Full Code Here

Examples of org.python.core.PyList

        dict.__setitem__("getPOSIX", null);
        dict.__setitem__("getOSName", null);
        dict.__setitem__("badFD", null);

        // Hide __doc__s
        PyList keys = (PyList)dict.invoke("keys");
        for (Iterator<?> it = keys.listIterator(); it.hasNext();) {
            String key = (String)it.next();
            if (key.startsWith("__doc__")) {
                it.remove();
                dict.__setitem__(key, null);
            }
View Full Code Here

Examples of org.python.core.PyList

                throw Py.OSError(Errno.EACCES, path);
            }
            throw Py.OSError("listdir(): an unknown error occured: " + path);
        }

        PyList list = new PyList();
        PyString string = (PyString) path;
        for (String name : names) {
            list.append(string.createInstance(name));
        }
        return list;
    }
View Full Code Here

Examples of org.python.core.PyList

    public static PyObject _get_shell_commands() {
        String[][] commands = os.getShellCommands();
        PyObject[] commandsTup = new PyObject[commands.length];
        int i = 0;
        for (String[] command : commands) {
            PyList args = new PyList();
            for (String arg : command) {
                args.append(new PyString(arg));
            }
            commandsTup[i++] = args;
        }
        return new PyTuple(commandsTup);
    }
View Full Code Here

Examples of org.python.core.PyList

            }
            // tuples are immutable, so we can just use its underlying array
            return new PyStatResult(((PyTuple)obj).getArray());
        }
        else {
            PyList seq = new PyList(obj);
            if (seq.__len__() != n_fields) {
                String msg = String.format("stat_result() takes a %s-sequence (%s-sequence given)",
                                           n_fields, obj.__len__());
                throw Py.TypeError(msg);
            }
            return new PyStatResult((PyObject[])seq.__tojava__(PyObject[].class));
        }
    }
View Full Code Here

Examples of org.python.core.PyList

        return new PyTuple(getType(), newargs);
    }

    @Override
    public PyTuple __getnewargs__() {
        return new PyTuple(new PyList(getArray()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.