Examples of PyFile


Examples of org.python.core.PyFile

    protected String getTestPath(String testName) {
        return "/test/pyservlet/" + testName + ".py";
    }

    private String readTestFile(String testName) {
        PyFile in = new PyFile(basePath + getTestPath(testName), "r", 4192);
        String result = in.read().toString();
        return result;
    }
View Full Code Here

Examples of org.python.core.PyFile

        String result = in.read().toString();
        return result;
    }

    private void writeToTestFile(String testName, String newContents) {
        PyFile out = new PyFile(basePath + getTestPath(testName), "w", 4192);
        out.write(newContents);
        out.close();
    }
View Full Code Here

Examples of org.python.core.PyFile

        }
    }

    private static PyObject newFile(File file) {
        try {
            return new PyFile(new FileInputStream(file));
        } catch (IOException ioe) {
            throw Py.IOError(ioe);
        }
    }
View Full Code Here

Examples of org.python.core.PyFile

    public static PyObject load_source(String modname, String filename, PyObject file) {
        PyObject mod = Py.None;
        if (file == null) {
            // XXX: This should load the accompanying byte code file instead, if it exists
            file = new PyFile(filename, "r", 1024);
        }
        Object o = file.__tojava__(InputStream.class);
        if (o == Py.NoConversion) {
            throw Py.TypeError("must be a file-like object");
        }
View Full Code Here

Examples of org.python.core.PyFile

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

    public static PyObject load_compiled(String name, String pathname) {
        return load_compiled(name, pathname, new PyFile(pathname, "rb", -1));
    }
View Full Code Here

Examples of org.python.core.PyFile

        if (rawIO.closed()) {
            throw badFD();
        }

        try {
            return new PyFile(rawIO, "<fdopen>", mode, bufsize);
        } catch (PyException pye) {
            if (!pye.match(Py.IOError)) {
                throw pye;
            }
            throw Py.OSError(Errno.EINVAL);
View Full Code Here

Examples of org.python.core.PyFile

    /**
     * Creates a PyFile that reads from the given <code>InputStream</code> with mode.
     */
    public static PyFile wrap(InputStream is, String mode) {
        return new PyFile(is, "<Java InputStream '" + is + "' as file>", mode, -1, true);   
    }
View Full Code Here

Examples of org.python.core.PyFile

    /**
     * Creates a PyFile that reads from the given <code>InputStream</code> with bufsize.
     */
    public static PyFile wrap(InputStream is, int bufsize) {
        return new PyFile(is, bufsize);
    }
View Full Code Here

Examples of org.python.core.PyFile

    /**
     * Creates a PyFile that writes to the given <code>OutputStream</code> with bufsize.
     */
    public static PyFile wrap(OutputStream os, int bufsize) {
        return new PyFile(os, bufsize);
    }
View Full Code Here

Examples of org.python.core.PyFile

       
        environ.put("QUERY_STRING", request.getResourceRef().getQuery());

        environ.put("wsgi.version", new PyTuple(new PyInteger(0), new PyInteger(1)));
        environ.put("wsgi.url_scheme", ref.getScheme());
        environ.put("wsgi.input", new PyFile(request.getEntity().getStream()));
        environ.put("wsgi.errors", new PyFile(System.err));
        environ.put("wsgi.multithread", true);
        environ.put("wsgi.multitprocess", false);
        environ.put("wsgi.run_once", false);
        return environ;
    }
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.