public static PyObject list_dialects() { return _dialects.keys(); }
/** * Merge another PyObject that supports keys() with this * dict. * * @param other a PyObject with a keys() method */ private void merge(PyObject other) { if (other instanceof PyStringMap) { table.putAll(((PyStringMap)other).table); } else if (other instanceof PyDictionary) { mergeFromKeys(other, ((PyDictionary)other).keys()); } else { mergeFromKeys(other, other.invoke("keys")); } }
/** * Equivalent to the standard Python __dir__ method. * * @return a list of names defined by this object. **/ public PyObject __dir__() { PyDictionary accum = new PyDictionary(); __rawdir__(accum); PyList ret = accum.keys(); ret.sort(); return ret; }
@Override public Map<String, Parameter<?>> getOutputs(ScriptEngine engine) throws ScriptException { PyDictionary outputs = (PyDictionary) process(engine).__getattr__("outputs"); Map<String, Parameter<?>> map = new TreeMap<String, Parameter<?>>(); for (String name : (List<String>) outputs.keys()) { PyTuple output = (PyTuple) outputs.get(name); Object type = output.__getitem__(0); Object desc = output.__getitem__(1); // map every key in the optional dictionary as parameter metadata entry Map<String, Object> metadata = null; if (output.size() == 3) { PyDictionary meta = (PyDictionary) output.get(2); if (meta != null && !meta.isEmpty()) { metadata = new HashMap<String, Object>(); for (Object key : meta.keySet()) { metadata.put((String) key, meta.get(key)); } } } map.put(name, parameter(name, type, 1, 1, desc, null, metadata)); } return map; }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.dict___eq___doc) final PyObject dict___eq__(PyObject otherObj) { PyType thisType = getType(); PyType otherType = otherObj.getType(); if (otherType != thisType && !thisType.isSubType(otherType) && !otherType.isSubType(thisType) || otherType == PyObject.TYPE) { return null; } PyDictionary other = (PyDictionary)otherObj; int an = getMap().size(); int bn = other.getMap().size(); if (an != bn) { return Py.False; } PyList akeys = keys(); for (int i = 0; i < an; i++) { PyObject akey = akeys.pyget(i); PyObject bvalue = other.__finditem__(akey); if (bvalue == null) { return Py.False; } PyObject avalue = __finditem__(akey); if (!avalue._eq(bvalue).__nonzero__()) { return Py.False; } } return Py.True; }
bkeys = ((PyStringMap)other).keys(); } else { bkeys = ((PyDictionary)other).keys();