def _iter_recursive_class(self, node, class_): for obj_id, child in compat.iteritems(node.children): if isinstance(child.data, class_): yield obj_id, child.data for data in self._iter_recursive_class(child, class_): yield data
def __init__(self, obj, **kw): '''Create mock object obj - Object to be mocked kw - Mocked attributes ''' self.obj = obj self._restore = [] for attr, val in compat.iteritems(kw): self._restore.append((attr, getattr(obj, attr))) setattr(self.obj, attr, val)
def __call__(self, obj, attrs): for key, (new_val, old_val) in compat.iteritems(attrs): prev_notification = self._new_val_old_vals.get(key) if prev_notification is not None: old_val = prev_notification[1] if new_val == old_val: self._new_val_old_vals.pop(key) else: self._new_val_old_vals[key] = (new_val, old_val)
def inject_dec(*args, **kwargs): pm = kwargs.get('pm') if pm is None: raise AssertionError( 'pm argument with PluginManager not passed (required for @inject).') for key, val in compat.iteritems(inject_kwargs): if key not in kwargs: if val.__class__ is list: kwargs[key] = pm.get_implementations(val[0]) else: kwargs[key] = pm.get_instance(val) return func(*args, **kwargs)
def declare_props(cls, **kwargs): frame = sys._getframe().f_back namespace = frame.f_locals props_namespace = namespace.get('__props__') if props_namespace is None: props_namespace = namespace['__props__'] = [] for key, val in compat.iteritems(kwargs): if isinstance(val, PropsCustomProperty): namespace[key] = val._make_property(key) else: namespace[key] = _make_property(key, val) props_namespace.append(key) if '__slots__' not in namespace: namespace['__slots__'] = []
def __init__(self, **kwds): QtGui.QTextBlockUserData.__init__(self) for key, value in compat.iteritems(kwds): setattr(self, key, value)
def __init__(self, **kwds): QtGui.QTextBlockUserData.__init__(self) for key, value in compat.iteritems(kwds): setattr(self, key, value)
def declare_props(cls, **kwargs): frame = sys._getframe().f_back namespace = frame.f_locals for key, val in compat.iteritems(kwargs): namespace[key] = _make_property(key, val)
def declare_props(cls, **kwargs): frame = sys._getframe().f_back namespace = frame.f_locals for key, val in compat.iteritems(kwargs): namespace[key] = _make_property(key, val)
def items(self): for key, node in compat.iteritems(self._fast): yield key, node.data
def _iter_recursive_no_class(self, node): for obj_id, child in compat.iteritems(node.children): yield obj_id, child.data for data in self._iter_recursive_no_class(child): yield data
def set_memento(self, memento): for key, val in compat.iteritems(memento): setattr(self, key, val)
def __init__(self, **kwargs): self._props = {} self._original_on_modified_callback = self._on_modified_callback = Callback( ) for key, val in compat.iteritems(kwargs): setattr(self, key, val)