@Override public void scanToAutoEnable() { PyScriptEngineScope scope = eval("globals()"); List<PyType> processorPyTypes = PROCESSOR_CLASSES.values().stream().map(cls -> (PyType) Py.java2py(cls)).collect(Collectors.toList()); List<Object> autoEnabled = new ArrayList<>(); SpongeUtils.stream(((ScopeIterator) scope.__iter__()).iterator()).forEachOrdered(element -> { String name = element.toString(); PyObject pyObject = scope.__finditem__(name); if (pyObject != null && pyObject instanceof PyType) { PyType pyType = (PyType) pyObject; if (processorPyTypes.stream().filter(processorClass -> !pyType.equals(processorClass) && pyType.isSubType(processorClass)) .findFirst().isPresent()) { if (!isProcessorAbstract(name)) { autoEnabled.add(name); ((JythonKnowledgeBaseEngineOperations) getEngineOperations()).enable(pyType); } } } }); if (logger.isDebugEnabled() && !autoEnabled.isEmpty()) { logger.debug("Auto-enabling: {}", autoEnabled); } }
/** * Ensures that the physical layout between this type and <code>other</code> are compatible. * Raises a TypeError if not. */ public void compatibleForAssignment(PyType other, String attribute) { if (!getLayout().equals(other.getLayout()) || needs_userdict != other.needs_userdict || needs_finalizer != other.needs_finalizer) { throw Py.TypeError(String.format("%s assignment: '%s' object layout differs from '%s'", attribute, other.fastGetName(), fastGetName())); } }
type.equals(PyDictionary.TYPE)) { return true;