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


Python UserDict.__init__方法代码示例

本文整理汇总了Python中collections.UserDict.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python UserDict.__init__方法的具体用法?Python UserDict.__init__怎么用?Python UserDict.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在collections.UserDict的用法示例。


在下文中一共展示了UserDict.__init__方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, socket_manager=None, module_manager=None, bot=None):
        UserDict.__init__(self)
        self.db_session = DBManager.create_session()

        self.internal_commands = {}
        self.db_commands = {}
        self.module_commands = {}
        self.data = {}

        self.bot = bot
        self.module_manager = module_manager

        if socket_manager:
            socket_manager.add_handler("module.update", self.on_module_reload)
            socket_manager.add_handler("command.update", self.on_command_update)
            socket_manager.add_handler("command.remove", self.on_command_remove) 
开发者ID:pajbot,项目名称:pajbot,代码行数:18,代码来源:command.py

示例2: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, type, fetch=False, check=False,
                 parent=None, recursive=1, session=None, **kwargs):
        assert('fq_name' in kwargs or 'uuid' in kwargs or 'to' in kwargs)
        super(Resource, self).__init__(session=session)
        self.type = type

        UserDict.__init__(self, kwargs)
        self.from_dict(self.data)

        if parent:
            self.parent = parent

        if check:
            self.check()

        if fetch:
            self.fetch(recursive=recursive)

        self.properties = {prop.key: prop for prop in self.schema.properties}
        self.emit('created', self) 
开发者ID:eonpatapon,项目名称:contrail-api-cli,代码行数:22,代码来源:resource.py

示例3: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, *maps):
        '''Initialize a ChainMap by setting *maps* to the given mappings.
        If no mappings are provided, a single empty dictionary is used.

        '''
        self.maps = list(maps) or [{}]          # always at least one map 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:8,代码来源:singledispatch_helpers.py

示例4: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, object, method, name=None):
        if name is None:
            name = method.__name__
        self.object = object
        self.method = method
        self.name = name
        setattr(self.object, name, self) 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:9,代码来源:Environment.py

示例5: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, filename=None, version=0):
        """
        Create an empty Env object or load an existing one from a file.

        If the version recorded in the file is lower than version, or if some
        error occurs during unpickling, or if filename is not supplied,
        create an empty Env object.

        :param filename: Path to an env file.
        :param version: Required env version (int).
        """
        IterableUserDict.__init__(self)
        empty = {"version": version}
        self._filename = filename
        self._sniffer = None
        self.save_lock = threading.RLock()
        if filename:
            try:
                if os.path.isfile(filename):
                    with open(filename, "rb") as f:
                        env = cPickle.load(f)
                    if env.get("version", 0) >= version:
                        self.data = env
                    else:
                        logging.warn(
                            "Incompatible env file found. Not using it.")
                        self.data = empty
                else:
                    # No previous env file found, proceed...
                    logging.warn("Creating new, empty env file")
                    self.data = empty
            # Almost any exception can be raised during unpickling, so let's
            # catch them all
            except Exception as e:
                logging.warn("Exception thrown while loading env")
                logging.warn(e)
                logging.warn("Creating new, empty env file")
                self.data = empty
        else:
            logging.warn("Creating new, empty env file")
            self.data = empty 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:43,代码来源:utils_env.py

示例6: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, attribute):
        self.attribute = attribute 
开发者ID:bq,项目名称:web2board,代码行数:4,代码来源:Util.py

示例7: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, streamer, kvi_id):
        self.key = f"{streamer}:kvi"
        self.id = kvi_id 
开发者ID:pajbot,项目名称:pajbot,代码行数:5,代码来源:kvi.py

示例8: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, *args, **kwargs):
        """ Create a Message object

        @type: string denoting the message type. Standardization efforts are in progress.
        @id: identifier for message. Usually a nonce or a DID. This combined with the type
            tell us how to interpret the message.
        other things: ambiguous data. Interpretation defined by type and id.

        """
        UserDict.__init__(self, *args, **kwargs)
        self.context = {}
        # Assign it an ID
        if '@id' not in self.data:
            self.data['@id'] = str(uuid.uuid4()) 
开发者ID:hyperledger-archives,项目名称:indy-agent,代码行数:16,代码来源:message.py

示例9: __init__

# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self):
        GObject.GObject.__init__(self)
        Perspective.__init__(self, "learn", _("Learn"))
        self.always_on = True

        self.dockLocation = addUserConfigPrefix("pydock-learn.xml")
        self.first_run = True 
开发者ID:pychess,项目名称:pychess,代码行数:9,代码来源:__init__.py


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