/** * @see #FileIO(PyString name, String mode) */ public FileIO(String name, String mode) { this(Py.newString(name), mode); }
@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(); } }
/** * Return true if the key (converted to lowercase) is not found in the exclude list. */ protected boolean excluded(PyObject key) { PyObject lowered = Py.newString(((PyString) key).lower()); return this.exclude.contains(lowered); }
public static PyObject newString(int address) { return address != 0 ? Py.newString(new String(IO.getZeroTerminatedByteArray(address))) : Py.None; }
public static final PyObject newString(long address) { return address != 0 ? Py.newString(new String(IO.getZeroTerminatedByteArray(address))) : Py.None; }
@Override public PyObject __call__(PyObject prompt) { return Py.newString(raw_input(prompt)); } };
/** * Return a newly instantiated PyException of the given type. * * @param type * @param msg * @return PyException */ public static PyException makeException(PyObject type, String msg) { return Py.makeException(type, msg == null ? Py.EmptyString : Py.newString(msg)); }
public void initialize(Properties preProperties, Properties postProperties, String[] argv, ClassLoader classLoader, ExtensiblePyObjectAdapter adapter) { postProperties.put(PySystemState.PYTHON_CACHEDIR_SKIP, "true"); PySystemState defaultState = PySystemState.doInitialize(preProperties, postProperties, argv, classLoader, adapter); defaultState.path.append(Py.newString("/from_SyspathAppendingInitializer_with_love")); } }
private static PyObject importModule(String name) { PyObject fromlist = new PyTuple(Py.newString("__doc__")); return __builtin__.__import__(name, null, null, fromlist); } }
private static void addCode(PyObject dict, String name, int code, String message) { PyObject nameObj = Py.newString(name); PyObject codeObj = Py.newInteger(code); dict.__setitem__(nameObj, codeObj); errorcode.__setitem__(codeObj, nameObj); }
@ExposedGet(name = "value") public PyObject getValue() { Memory m = getMemory(); return !m.isNull() ? Py.newString(new String(m.getZeroTerminatedByteArray(0))) : Py.None; }
@ExposedGet(name = "keywords") public PyObject getKeywords() { if (keywords.length == 0) { return Py.None; } int argc = args.length - keywords.length; PyObject kwDict = new PyDictionary(); for (int i = 0; i < keywords.length; i++) { kwDict.__setitem__(Py.newString(keywords[i]), args[argc + i]); } return kwDict; }
public static PyObject newDecimal(String decimal) { if (decimal == null) { return Py.None; } PyObject decimalModule = __builtin__.__import__("decimal"); PyObject decimalClass = decimalModule.__getattr__("Decimal"); return decimalClass.__call__(newString(decimal)); }
public static void classDictInit(PyObject dict) { dict.__setitem__("__name__", Py.newString("_hashlib")); dict.__setitem__("algorithmMap", null); dict.__setitem__("classDictInit", null); }
private static PyObject buildClass(PyObject dict, String classname, String superclass, PyObject classDict, String doc) { classDict.__setitem__("__doc__", Py.newString(doc)); PyType type = (PyType)Py.makeClass("exceptions." + classname, dict.__finditem__(superclass), classDict); type.builtin = true; dict.__setitem__(classname, type); return type; }
static void raise_errmsg(String msg, PyObject s, PyObject pos, PyObject end) { /* Use the Python function json.decoder.errmsg to raise a nice looking ValueError exception */ final PyObject errmsg_fn = get_errmsg_fn(); if (errmsg_fn != null) { throw Py.ValueError(errmsg_fn.__call__(Py.newString(msg), s, pos, end).asString()); } else { throw Py.ValueError(msg); } }
public static void classDictInit(PyObject dict) { dict.__setitem__("__name__", Py.newString("_threading")); dict.__setitem__("Lock", Lock.TYPE); dict.__setitem__("RLock", RLock.TYPE); dict.__setitem__("_Lock", Lock.TYPE); dict.__setitem__("_RLock", RLock.TYPE); dict.__setitem__("Condition", Condition.TYPE); // Hide from Python dict.__setitem__("classDictInit", null); }
public static void classDictInit(PyObject dict) { dict.__setitem__("__doc__", __doc__); dict.__setitem__("__name__", Py.newString("_weakref")); dict.__setitem__("ref", ReferenceType.TYPE); dict.__setitem__("ReferenceType", ReferenceType.TYPE); dict.__setitem__("ProxyType", ProxyType.TYPE); dict.__setitem__("CallableProxyType", CallableProxyType.TYPE); // __doc__, functions: getweakrefcount, getweakrefs, proxy dict.__setitem__("classDictInit", null); }
public static void classDictInit(PyObject dict) { dict.__setitem__("__name__", Py.newString("_csv")); dict.__setitem__("__doc__", __doc__); dict.__setitem__("Dialect", PyDialect.TYPE); dict.__setitem__("Error", Error); for (QuoteStyle style : QuoteStyle.values()) { dict.__setitem__(style.name(), Py.newInteger(style.ordinal())); } dict.__setitem__("classDictInit", null); dict.__setitem__("field_limit", null); }