本文整理汇总了Java中org.python.core.Py.TypeError方法的典型用法代码示例。如果您正苦于以下问题:Java Py.TypeError方法的具体用法?Java Py.TypeError怎么用?Java Py.TypeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.core.Py
的用法示例。
在下文中一共展示了Py.TypeError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: utime
import org.python.core.Py; //导入方法依赖的package包/类
public static void utime(PyObject path, PyObject times) {
long[] atimeval;
long[] mtimeval;
if (times == Py.None) {
atimeval = mtimeval = null;
} else if (times instanceof PyTuple && times.__len__() == 2) {
atimeval = extractTimeval(times.__getitem__(0));
mtimeval = extractTimeval(times.__getitem__(1));
} else {
throw Py.TypeError("utime() arg 2 must be a tuple (atime, mtime)");
}
if (posix.utimes(absolutePath(path), atimeval, mtimeval) < 0) {
throw errorFromErrno(path);
}
}
示例2: parse
import org.python.core.Py; //导入方法依赖的package包/类
public void parse(PyObject[] args, String[] kws) {
int nargs = args.length - kws.length;
if (nargs < fixedArgs.length) {
// TODO I need to verify these exceptions bubble up correctly
throw Py.TypeError(String.format("Not enough arguments to %s(): %d provided, %d needed",
funcname, nargs, fixedArgs.length));
}
// fixed arguments
for (int i=0; i < fixedArgs.length; i++) {
this.args.put(fixedArgs[i], args[i]);
}
// keyword arguments
for (int i=0; i < kws.length; i++) {
if (!this.keywordArgs.contains(kws[i])) {
throw Py.TypeError(String.format("Unexpected keyword argument to %s(): %s",
funcname, kws[i]));
}
this.args.put(kws[i], args[nargs + i]);
}
}
示例3: isatty
import org.python.core.Py; //导入方法依赖的package包/类
public static boolean isatty(PyObject fdObj) {
if (fdObj instanceof PyInteger) {
FileDescriptor fd;
switch (fdObj.asInt()) {
case 0:
fd = FileDescriptor.in;
break;
case 1:
fd = FileDescriptor.out;
break;
case 2:
fd = FileDescriptor.err;
break;
default:
throw Py.NotImplementedError("Integer file descriptor compatibility only "
+ "available for stdin, stdout and stderr (0-2)");
}
return posix.isatty(fd);
}
Object tojava = fdObj.__tojava__(FileDescriptor.class);
if (tojava != Py.NoConversion) {
return posix.isatty((FileDescriptor)tojava);
}
tojava = fdObj.__tojava__(IOBase.class);
if (tojava == Py.NoConversion) {
throw Py.TypeError("a file descriptor is required");
}
return ((IOBase)tojava).isatty();
}
示例4: asPath
import org.python.core.Py; //导入方法依赖的package包/类
/**
* Return a path as a String from a PyObject
*
* @param path a PyObject, raising a TypeError if an invalid path type
* @return a String path
*/
private static String asPath(PyObject path) {
if (path instanceof PyString) {
return path.toString();
}
throw Py.TypeError(String.format("coercing to Unicode: need string, %s type found",
path.getType().fastGetName()));
}
示例5: get
import org.python.core.Py; //导入方法依赖的package包/类
public PyObject get(String name) {
PyObject value = this.args.get(name);
if(value == null) {
throw Py.TypeError(String.format("Missing argument to %s(): %s",
funcname, name));
}
return value;
}
示例6: roof
import org.python.core.Py; //导入方法依赖的package包/类
public static void roof(ArgParser r, World world, BlockPos pos, EnumFacing facing) throws BlockTypeError {
int aWidth = r.getInteger("width");
int aDepth = r.getInteger("depth");
if (aWidth < 2) {
throw Py.TypeError("width must be > 1");
}
if (aDepth < 2) {
throw Py.TypeError("depth must be > 1");
}
String style = r.getString("style", "hip");
boolean box = false;
if (style.startsWith("box-")) {
box = true;
style = style.substring(4);
}
RoofGen gen = new RoofGen((WorldServer) world, pos, facing,
r.getString("blockname"), aWidth, aDepth, r);
switch (style) {
case "hip":
gen.hip();
break;
case "gable":
gen.gable(box);
break;
case "shed":
gen.shed(box);
break;
default:
throw Py.TypeError(String.format("unknown style '%s'", r.getString("style")));
}
}
示例7: getFloat
import org.python.core.Py; //导入方法依赖的package包/类
public static double getFloat(ArgParser ap, int position)
/* */ {
/* 129 */ PyObject arg = ap.getPyObject(position);
/* */
/* 131 */ if (Py.isInstance(arg, PyFloat.TYPE)) {
/* 132 */ return ((PyFloat)arg).asDouble();
/* */ }
/* 134 */ if (Py.isInstance(arg, PyInteger.TYPE)) {
/* 135 */ return ((PyInteger)arg).asDouble();
/* */ }
/* 137 */ throw Py.TypeError("Unable to parse argument: " + position);
/* */ }