当前位置: 首页>>代码示例>>Python>>正文


Python WeakValueDictionary.__init__方法代码示例

本文整理汇总了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)
开发者ID:JukeboxPipeline,项目名称:jukeboxmaya,代码行数:34,代码来源:menu.py

示例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)
开发者ID:Veterini,项目名称:translate,代码行数:10,代码来源:lru.py

示例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
开发者ID:yrttyr,项目名称:Multiplayer-snake-game,代码行数:10,代码来源:objects.py

示例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
开发者ID:antonwang,项目名称:pygr,代码行数:13,代码来源:classutil.py

示例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
开发者ID:BD2KGenomics,项目名称:brca-pipeline,代码行数:13,代码来源:classutil.py

示例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
开发者ID:oaubert,项目名称:advene2,代码行数:14,代码来源:reftools.py

示例7: __init__

# 需要导入模块: from weakref import WeakValueDictionary [as 别名]
# 或者: from weakref.WeakValueDictionary import __init__ [as 别名]
 def __init__(self):
     WeakValueDictionary.__init__(self)
开发者ID:motoz,项目名称:PellMon,代码行数:4,代码来源:database.py

示例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)
开发者ID:AndryulE,项目名称:kitsune,代码行数:7,代码来源:lru.py


注:本文中的weakref.WeakValueDictionary.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。