當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。