@Override public PyObject __iternext__() { if (!iterator.hasNext()) { return null; } Entry<PyObject, PyObject> entry = iterator.next(); return new PyTuple(entry.getKey(), entry.getValue()); } }
private static PyTuple toPyStringTuple(String[] ar) { if (ar == null) { return Py.EmptyTuple; } int sz = ar.length; PyString[] pystr = new PyString[sz]; for (int i = 0; i < sz; i++) { pystr[i] = new PyString(ar[i]); } return new PyTuple(pystr); }
@Override public PyObject __call__() { PyList items = new PyList(); for (Map.Entry<Object, Object> entry : asMap().entrySet()) { items.add(new PyTuple(Py.java2py(entry.getKey()), Py.java2py(entry.getValue()))); } return items; } };
@ExposedMethod(doc = BuiltinDocs.unicode__formatter_field_name_split_doc) final PyObject unicode__formatter_field_name_split() { FieldNameIterator iterator = new FieldNameIterator(this); return new PyTuple(iterator.pyHead(), iterator); }
public static PyTuple utf_16_ex_decode(String str, String errors, int byteorder, boolean final_) { int[] bo = new int[] {0}; int[] consumed = final_ ? null : new int[1]; String decoded = decode_UTF16(str, errors, bo, consumed); return new PyTuple(new PyUnicode(decoded), Py.newInteger(final_ ? str.length() : consumed[0]), Py.newInteger(bo[0])); }
public static PyException IOError(Constant errno) { int value = errno.intValue(); PyObject args = new PyTuple(Py.newInteger(value), PosixModule.strerror(value)); return new PyException(Py.IOError, args); }
@ExposedMethod final PyObject deque___reduce__() { PyObject dict = getDict(); if (dict == null) { dict = Py.None; } return new PyTuple(getType(), Py.EmptyTuple, dict, __iter__()); }
public static PyException IOError(Constant errno, PyObject filename) { int value = errno.intValue(); PyObject args = new PyTuple(Py.newInteger(value), PosixModule.strerror(value), filename); return new PyException(Py.IOError, args); }
public static void SystemExit__init__(PyObject self, PyObject[] args, String[] kwargs) { PyBaseException.TYPE.invoke("__init__", self, args, kwargs); initSlots(self); if (args.length == 1) { self.__setattr__("code", args[0]); } else if (args.length > 1) { self.__setattr__("code", new PyTuple(args)); } }
public static PyTuple polar(PyObject in) { PyComplex z = complexFromPyObject(in); double phi = Math.atan2(z.imag, z.real); double r = math.hypot(z.real, z.imag); return new PyTuple(new PyFloat(r), new PyFloat(phi)); }
@Hide(posixImpl = PosixImpl.JAVA) public static PyObject waitpid(int pid, int options) { int[] status = new int[1]; pid = posix.waitpid(pid, status, options); if (pid < 0) { throw errorFromErrno(); } return new PyTuple(Py.newInteger(pid), Py.newInteger(status[0])); }
public static PyException UnicodeTranslateError(String object, int start, int end, String reason) { return new PyException(Py.UnicodeTranslateError, new PyTuple(new PyString(object), new PyInteger(start), new PyInteger(end), new PyString(reason))); } public static PyObject UnicodeDecodeError;
@Override public PyObject __rdivmod__(PyObject left) { if (!canCoerce(left)) { return null; } double leftv = coerce(left); if (getValue() == 0) { throw Py.ZeroDivisionError("float division"); } double z = Math.floor(leftv / getValue()); return new PyTuple(new PyFloat(z), new PyFloat(leftv - z * getValue())); }
@ExposedMethod public String toString() { String owner = _lock.getOwnerName(); return Py.newString("<_threading.RLock owner=%r count=%d>"). __mod__(new PyTuple( owner != null ? Py.newStringOrUnicode(owner) : Py.None, Py.newInteger(_lock.getHoldCount()))).toString(); } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdivmod___doc) final PyObject int___rdivmod__(PyObject left) { if (!canCoerce(left)) { return null; } int leftv = coerce(left); int v = getValue(); long xdivy = divide(leftv, v); return new PyTuple(Py.newInteger(xdivy), Py.newInteger(modulo(leftv, v, xdivy))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rdivmod___doc) final PyObject long___rdivmod__(PyObject left) { if (!canCoerce(left)) { return null; } BigInteger leftv = coerce(left); BigInteger xdivy = divide(leftv, getValue()); return new PyTuple(Py.newLong(xdivy), Py.newLong(modulo(leftv, getValue(), xdivy))); }