本文整理匯總了Java中org.python.core.PyFile類的典型用法代碼示例。如果您正苦於以下問題:Java PyFile類的具體用法?Java PyFile怎麽用?Java PyFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PyFile類屬於org.python.core包,在下文中一共展示了PyFile類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fdopen
import org.python.core.PyFile; //導入依賴的package包/類
public static PyObject fdopen(PyObject fd, String mode, int bufsize) {
if (mode.length() == 0 || !"rwa".contains("" + mode.charAt(0))) {
throw Py.ValueError(String.format("invalid file mode '%s'", mode));
}
RawIOBase rawIO = FileDescriptors.get(fd);
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((Constant)Errno.EINVAL);
}
}
示例2: keyIsExcluded
import org.python.core.PyFile; //導入依賴的package包/類
private boolean keyIsExcluded(String key, PyObject value) {
return (key.startsWith("__") && key.endsWith("__")) ||
value instanceof PyFile ||
value instanceof PyModule ||
value instanceof PyFunction ||
value instanceof PySystemState ||
value instanceof PyClass ||
value instanceof PyType ||
value instanceof PyReflectedFunction;
}
示例3: loadScript
import org.python.core.PyFile; //導入依賴的package包/類
public static List<String> loadScript(String path) throws FileNotFoundException {
PyFile file = new PyFile(new FileInputStream(new File(path)));
PyList lines = (PyList) file.readlines();
return (List<String>)lines;
}
示例4: readScript
import org.python.core.PyFile; //導入依賴的package包/類
public List<String> readScript(String path) throws FileNotFoundException {
InputStream inputStream = getClass().getResourceAsStream("/" + path);
PyFile file = new PyFile(inputStream);
PyList lines = (PyList) file.readlines();
return (List<String>)lines;
}