本文整理汇总了Python中weakref.WeakValueDictionary.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python WeakValueDictionary.__init__方法的具体用法?Python WeakValueDictionary.__init__怎么用?Python WeakValueDictionary.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weakref.WeakValueDictionary
的用法示例。
在下文中一共展示了WeakValueDictionary.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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)
示例2: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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)
示例3: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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
示例4: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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
示例5: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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
示例6: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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
示例7: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
def __init__(self):
WeakValueDictionary.__init__(self)
示例8: __init__
# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
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)