Package org.python.core

Examples of org.python.core.PyList


         * @return      a list of the lines.
         */
        public PyObject readlines(int sizehint) {
            opencheck();
            int total = 0;
            PyList lines = new PyList();
            String line = readline();
            while (line.length() > 0) {
                lines.append(new PyString(line));
                total += line.length();
                if (0 < sizehint && sizehint <= total)
                    break;
                line = readline();
            }
View Full Code Here


                        throw Py.IOError(e);
                    }
                    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, true);
                    type = mi.type;
                    file = mi.file;
                    filename = new PyString(mi.filename);
View Full Code Here

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

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

        PyTuple newargs = __getnewargs__();
        return new PyTuple(new PyObject[] { getType(), newargs });
    }

    public PyTuple __getnewargs__() {
        return new PyTuple(new PyObject[] { new PyList(getArray()) });
    }
View Full Code Here

        int size = calcsize(format, f);

        if (size != len)
            throw StructError("unpack str size does not match format");

        PyList res = new PyList();

        ByteStream str = new ByteStream(string);

        int flen = format.length();
        for (int j = 0; j < flen; j++) {
View Full Code Here

    final PyObject baseset___reduce__() {
        String name = getType().getFullName();
        PyObject factory = __builtin__.__import__("setsfactory");
        PyObject func = factory.__getattr__(name);
        return new PyTuple(new PyObject[] { func, new PyTuple(new PyObject[] { new PyList((PyObject) this) }) });
    }
View Full Code Here

        byte[] bytes = new byte[length.intValue()];
        inputStream.read(bytes);
        String payload = new String(bytes, ISO_8859_1);

        PyString pyString = new PyString(payload);
        PyList pyList = (PyList) cPickle.loads(pyString);

        return Lists.transform(pyList, new PythonToJava());
    }
View Full Code Here

    assertTrue(fourPointThree instanceof Double);
    assertEquals(4.3, (Double) fourPointThree, DELTA);

    PyObject listResult = getListFunc.__call__(foo);
    assertTrue(listResult instanceof PyList);
    PyList pyListResult = (PyList) listResult;
    assertEquals(3, pyListResult.size());
    assertEquals(2, pyListResult.get(0));
    assertEquals(9, pyListResult.get(1));
    assertEquals(11, pyListResult.get(2));

    PyObject ivalResult = getIValFunc.__call__(foo);
    assertTrue(ivalResult instanceof PyInteger);
    assertEquals(17, ((PyInteger) ivalResult).getValue());
  }
View Full Code Here

            throw StructError("unpack_from str size does not match format");
        return unpack(f, size, format, new ByteStream(string, offset));
    }
   
    static PyTuple unpack(FormatDef[] f, int size, String format, ByteStream str) {
        PyList res = new PyList();
        int flen = format.length();
        for (int j = 0; j < flen; j++) {
            char c = format.charAt(j);
            if (j == 0 && (c=='@' || c=='<' || c=='>' || c=='=' || c=='!'))
                continue;
View Full Code Here

        }

        // Setup the basic python system state from these options
        PySystemState.initialize(PySystemState.getBaseProperties(), opts.properties, opts.argv);

        PyList warnoptions = new PyList();
        for (String wopt : opts.warnoptions) {
            warnoptions.append(new PyString(wopt));
        }
        Py.getSystemState().setWarnoptions(warnoptions);

        PySystemState systemState = Py.getSystemState();
        // Decide if stdin is interactive
View Full Code Here

TOP

Related Classes of org.python.core.PyList

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.