/** * Returns {@link PyObject#__len__()}. */ public int size() throws TemplateModelException { try { return object.__len__(); } catch (PyException e) { throw new TemplateModelException(e); } }
/** * Returns {@link PyObject#__len__()}<code> == 0</code>. */ public boolean isEmpty() throws TemplateModelException { try { return object.__len__() == 0; } catch (PyException e) { throw new TemplateModelException(e); } }
/** * Returns {@link PyObject#__len__()}. */ public int size() throws TemplateModelException { try { return object.__len__(); } catch (PyException e) { throw new TemplateModelException(e); } }
ScopeIterator(PyScriptEngineScope scope) { _keys = scope.scope_keys(); _size = _keys.__len__(); _index = -1; }
final private PyObject[] make_array(PyObject seq) { int n = seq.__len__(); PyObject[] objs= new PyObject[n]; for(int i=0; i<n; i++) objs[i] = seq.__finditem__(i); return objs; }
/** * Returns {@link PyObject#__len__()}. */ public int size() throws TemplateModelException { try { return object.__len__(); } catch (PyException e) { throw new TemplateModelException(e); } }
/** * Returns {@link PyObject#__len__()}. */ public int size() throws TemplateModelException { try { return object.__len__(); } catch (PyException e) { throw new TemplateModelException(e); } }
private static char toChar(String name, PyObject src, char dflt) { if (src == null) { return dflt; } boolean isStr = Py.isInstance(src, PyString.TYPE); if (src == Py.None || isStr && src.__len__() == 0) { return '\0'; } else if (!isStr || src.__len__() != 1) { throw Py.TypeError(String.format("\"%s\" must be an 1-character string", name)); } return src.toString().charAt(0); }
public void checkIdxAndSetSlice(PySlice slice, PyObject value) { int[] indices = slice.indicesEx(len()); if ((slice.step != Py.None) && value.__len__() != indices[3]) { throw Py.ValueError(String.format("attempt to assign sequence of size %d to extended " + "slice of size %d", value.__len__(), indices[3])); } setSlice(indices[0], indices[1], indices[2], value); }
void pack(ByteStream buf, PyObject value) { if (!(value instanceof PyString) || value.__len__() != 1) throw StructError("char format require string of length 1"); buf.writeByte(value.toString().charAt(0)); }
final PyObject dict_view___gt__(PyObject otherObj) { if (!isSetDictViewInstance(otherObj)) { return Py.False; } if (this.__len__() > otherObj.__len__()) { if (allContainedIn(otherObj, this)) { return Py.False; } } return Py.True; }
final PyObject dict_view___lt__(PyObject otherObj) { if (!isSetDictViewInstance(otherObj)) { return Py.False; } if (this.__len__() < otherObj.__len__()) { if (allContainedIn(this, otherObj)) { return Py.False; } } return Py.True; }
final PyObject dict_view___ge__(PyObject otherObj) { if (!isSetDictViewInstance(otherObj)) { return Py.False; } if (this.__len__() >= otherObj.__len__()) { if (allContainedIn(otherObj, this)) { return Py.False; } } return Py.True; }
final PyObject dict_view___le__(PyObject otherObj) { if (!isSetDictViewInstance(otherObj)) { return Py.False; } if (this.__len__() <= otherObj.__len__()) { if (allContainedIn(this, otherObj)) { return Py.False; } } return Py.True; }
final PyObject seq___eq__(PyObject o) { if (!isSubType(o) || o.getType() == PyObject.TYPE) { return null; } int tl = __len__(); int ol = o.__len__(); if (tl != ol) { return Py.False; } int i = cmp(this, tl, o, ol); return i < 0 ? Py.True : Py.False; }
final PyObject seq___ne__(PyObject o) { if (!isSubType(o) || o.getType() == PyObject.TYPE) { return null; } int tl = __len__(); int ol = o.__len__(); if (tl != ol) { return Py.True; } int i = cmp(this, tl, o, ol); return i < 0 ? Py.False : Py.True; }
@ExposedMethod(doc = BuiltinDocs.BaseException___str___doc) final PyString BaseException___str__() { switch (args.__len__()) { case 0: return Py.EmptyString; case 1: return args.__getitem__(0).__str__(); default: return args.__str__(); } }
public String[] getEnv() { PyObject items = imp.load("os").__getattr__("environ").invoke("items"); String[] env = new String[items.__len__()]; int i = 0; for (PyObject item : items.asIterable()) { env[i++] = String.format("%s=%s", item.__getitem__(0), item.__getitem__(1)); } return env; }
public int __len__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__len__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); return res.asInt(); } return super.__len__(); }
public static PyString _UnpickleableError__str__(PyObject self, PyObject[] args, String[] kwargs) { PyObject selfArgs = self.__getattr__("args"); PyObject a = selfArgs.__len__() > 0 ? selfArgs.__getitem__(0) : new PyString("(what)"); return new PyString("Cannot pickle %s objects").__mod__(a).__str__(); }