def __init__(self, maxsize, cullsize=2, peakmult=10, aggressive_gc=True, *args, **kwargs): self.cullsize = max(2, cullsize) self.maxsize = max(cullsize, maxsize) self.aggressive_gc = aggressive_gc self.peakmult = peakmult self.queue = deque() WeakValueDictionary.__init__(self, *args, **kwargs)
def __init__(self, name, parent=None, nolabel=False, **kwargs): """ Creates a maya menu or menu item :param name: Used to access a menu via its parent. Unless the nolabel flag is set to True, the name will also become the label of the menu. :type name: str :param parent: Optional - The parent menu. If None, this will create a toplevel menu. If parent menu is a Menu instance, this will create a menu item. Default is None. :type parent: Menu|None :param nolabel: Optional - If nolabel=True, the label flag for the maya command will not be overwritten by name :type nolabel: bool :param kwargs: all keyword arguments used for the cmds.menu/cmds.menuitem command :type kwargs: named arguments :returns: None :rtype: None :raises: errors.MenuExistsError """ WeakValueDictionary.__init__(self) self.__menustring = None self.__parent = parent self.__name = name self.__kwargs = kwargs if not nolabel: self.__kwargs['label'] = name if parent is not None: if name in parent: raise errors.MenuExistsError( "A menu with this name: %s and parent: %s exists already!" % (name, parent)) cmds.setParent(parent.menustring(), menu=1) self.__kwargs['parent'] = parent.menustring() self.__menustring = cmds.menuItem(**self.__kwargs) parent[name] = self else: cmds.setParent('MayaWindow') self.__menustring = cmds.menu(**self.__kwargs)
def __init__(self, name, parent=None, nolabel=False, **kwargs): """ Creates a maya menu or menu item :param name: Used to access a menu via its parent. Unless the nolabel flag is set to True, the name will also become the label of the menu. :type name: str :param parent: Optional - The parent menu. If None, this will create a toplevel menu. If parent menu is a Menu instance, this will create a menu item. Default is None. :type parent: Menu|None :param nolabel: Optional - If nolabel=True, the label flag for the maya command will not be overwritten by name :type nolabel: bool :param kwargs: all keyword arguments used for the cmds.menu/cmds.menuitem command :type kwargs: named arguments :returns: None :rtype: None :raises: errors.MenuExistsError """ WeakValueDictionary.__init__(self) self.__menustring = None self.__parent = parent self.__name = name self.__kwargs = kwargs if not nolabel: self.__kwargs['label'] = name if parent is not None: if name in parent: raise errors.MenuExistsError("A menu with this name: %s and parent: %s exists already!" % (name, parent)) cmds.setParent(parent.menustring(), menu=1) self.__kwargs['parent'] = parent.menustring() self.__menustring = cmds.menuItem(**self.__kwargs) parent[name] = self else: cmds.setParent('MayaWindow') self.__menustring = cmds.menu(**self.__kwargs)
def __init__(self): SendObject.__init__(self) WeakValueDictionary.__init__(self) def remove_wr(wr, selfref=ref(self)): self = selfref() if self is not None: del self[wr.key] self._remove = remove_wr
def __init__(self, n=None): WeakValueDictionary.__init__(self) if n<1: # user doesn't want any Most Recent value queue self.__class__ = WeakValueDictionary # revert to regular WVD return if isinstance(n, int): self.n = n # size limit else: self.n = 50 self.i = 0 # counter self._keepDict = {} # most recent queue
def __init__(self, n=None): WeakValueDictionary.__init__(self) if n < 1: # user doesn't want any Most Recent value queue self.__class__ = WeakValueDictionary # revert to regular WVD return if n is True: # assign default value self.n = 50 else: self.n = int(n) # size limit self._head = self._tail = None self._keepDict = {} # most recent queue
def __init__(self, n=None): WeakValueDictionary.__init__(self) if n<1: # user doesn't want any Most Recent value queue self.__class__ = WeakValueDictionary # revert to regular WVD return if n is True: # assign default value self.n = 50 else: self.n = int(n) # size limit self._head = self._tail = None self._keepDict = {} # most recent queue
def __init__(self, callback): WeakValueDictionary.__init__ (self) # The superclass WeakValueDictionary assigns self._remove as a # callback to all the KeyedRef it creates. So we have to override # self._remove. # Note however that self._remobe is *not* a method because, as a # callback, it can be invoked after the dictionary is collected. # So it is a plain function, stored as an *instance* attribute. def remove(wr, _callback=callback, _original=self._remove): _original(wr) _callback(wr.key) self._remove = remove
def __init__(self, maxsize, cullsize=2, *args, **kwargs): self.cullsize = max(2, cullsize) self.maxsize = max(cullsize, maxsize) self.queue = deque() WeakValueDictionary.__init__(self, *args, **kwargs)
def __init__(self): WeakValueDictionary.__init__(self) self._counter = counter()
def __init__(self): WeakValueDictionary.__init__(self)
def __init__(self, *args, **kw): super(WeakCache, self).__init__(*args, **kw) WeakValueDictionary.__init__(self)