本文整理汇总了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)
示例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)
示例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
示例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)
示例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
示例6: __init__
# 需要导入模块: from collections import UserDict [as 别名]
# 或者: from collections.UserDict import __init__ [as 别名]
def __init__(self, attribute):
self.attribute = attribute
示例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
示例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())
示例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