当前位置: 首页>>代码示例>>Java>>正文


Java Py.TypeError方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:17,代码来源:PosixModule.java

示例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]);
    }
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:24,代码来源:ArgParser.java

示例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();
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:32,代码来源:PosixModule.java

示例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()));
}
 
开发者ID:RunasSudo,项目名称:PyAndroid,代码行数:14,代码来源:PosixModule.java

示例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;
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:9,代码来源:ArgParser.java

示例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")));
    }
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:34,代码来源:RoofGen.java

示例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);
/*     */   }
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:13,代码来源:JythonUtils.java


注:本文中的org.python.core.Py.TypeError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。