Package org.python.core

Examples of org.python.core.PyTuple


            pop();
            push(new PyTuple(arr));
        }

        final private void load_empty_tuple() {
            push(new PyTuple(Py.EmptyObjects));
        }
View Full Code Here


        private void load_small_tuple(int length) {
            PyObject[] data = new PyObject[length];
            for(int i=length-1; i >= 0; i--) {
                data [i] = pop();
            }
            push(new PyTuple(data));
        }
View Full Code Here

                } else {
                    currentKey = keyFunc.__call__(currentValue);
                }
            }
            targetKey = currentKey;
            return new PyTuple(currentKey, new GroupByIterator());
        }
View Full Code Here

        return find_module(name, Py.None);
    }

    public static PyObject find_module(String name, PyObject path) {
        if (path == Py.None && PySystemState.getBuiltin(name) != null) {
            return new PyTuple(Py.None, Py.newString(name),
                               new PyTuple(Py.EmptyString, Py.EmptyString,
                                           Py.newInteger(C_BUILTIN)));
        }

        if (path == Py.None) {
            path = Py.getSystemState().path;
        }
        for (PyObject p : path.asIterable()) {
            ModuleInfo mi = findFromSource(name, p.toString(), false, true);
            if(mi == null) {
                continue;
            }
            return new PyTuple(mi.file,
                               new PyString(mi.filename),
                               new PyTuple(new PyString(mi.suffix),
                                           new PyString(mi.mode),
                                           Py.newInteger(mi.type)));
        }
        throw Py.ImportError("No module named " + name);
    }
View Full Code Here

        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

            PyObject file_offset = Py.newInteger(-1);
            PyObject time = new PyInteger(epochToDosTime(zipEntry.getTime()));
            PyObject date = new PyInteger(epochToDosDate(zipEntry.getTime()));
            PyObject crc = new PyLong(zipEntry.getCrc());

            PyTuple entry = new PyTuple(__file__, compress, data_size, file_size, file_offset,
                                        time, date, crc);
            files.__setitem__(new PyString(name), entry);
        }
    }
View Full Code Here

        if (leftbits != 0 && !done) {
            throw new PyException(Incomplete,
                                  "String has incomplete number of bytes");
        }

        return new PyTuple(Py.java2py(bin_data.toString()), Py.newInteger(done ? 1 : 0));
    }
View Full Code Here

        private void write_strings(String[] some_strings, int depth) {
            PyObject items[] = new PyObject[some_strings.length];
            for (int i = 0; i < some_strings.length; i++) {
                items[i] = Py.newString(some_strings[i]);
            }
            write_object(new PyTuple(items), depth + 1);
        }
View Full Code Here

                write_byte(TYPE_STRING);
                write_int(v.__len__());
                write_string(v.toString());
            } else if (v instanceof PyTuple) {
                write_byte(TYPE_TUPLE);
                PyTuple t = (PyTuple) v;
                int n = t.__len__();
                write_int(n);
                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()) {
                    PyTuple pair = (PyTuple) item;
                    write_object(pair.__getitem__(0), depth + 1);
                    write_object(pair.__getitem__(1), depth + 1);
                }
                write_object(null, depth + 1);
            } else if (v instanceof BaseSet) {
                if (v instanceof PySet) {
                    write_byte(TYPE_SET);
                } else {
                    write_byte(TYPE_FROZENSET);
                }
                int n = v.__len__();
                write_int(n);
                BaseSet set = (BaseSet) v;
                for (PyObject item : set.asIterable()) {
                    write_object(item, depth + 1);
                }
            } else if (v instanceof PyBytecode) {
                PyBytecode code = (PyBytecode) v;
                write_byte(TYPE_CODE);
                write_int(code.co_argcount);
                write_int(code.co_nlocals);
                write_int(code.co_stacksize);
                write_int(code.co_flags.toBits());
                write_object(Py.newString(new String(code.co_code)), depth + 1);
                write_object(new PyTuple(code.co_consts), depth + 1);
                write_strings(code.co_names, depth + 1);
                write_strings(code.co_varnames, depth + 1);
                write_strings(code.co_freevars, depth + 1);
                write_strings(code.co_cellvars, depth + 1);
                write_object(Py.newString(code.co_name), depth + 1);
View Full Code Here

    public static PyString __doc__rename = new PyString(
        "rename(old, new)\n\n" +
        "Rename a file or directory.");
    public static void rename(PyObject oldpath, PyObject newpath) {
        if (!new File(absolutePath(oldpath)).renameTo(new File(absolutePath(newpath)))) {
            PyObject args = new PyTuple(Py.Zero, new PyString("Couldn't rename file"));
            throw new PyException(Py.OSError, args);
        }
    }
View Full Code Here

TOP

Related Classes of org.python.core.PyTuple

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.