本文整理汇总了Python中connection.Connection.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.from_dict方法的具体用法?Python Connection.from_dict怎么用?Python Connection.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection.Connection
的用法示例。
在下文中一共展示了Connection.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_dict
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import from_dict [as 别名]
def from_dict(cls, config, additional_requirements=None):
requirements = additional_requirements or []
requirements.extend(config['requirements'])
blocks = [OpenBoxBlock.from_dict(block_config) for block_config in config['blocks']]
block_names = set(block.name for block in blocks)
connections = []
for connection_config in config['connections']:
connection = Connection.from_dict(connection_config)
if connection.src not in block_names:
raise OpenBoxConfigurationError(
"{src} in connection's source block is undefined".format(src=connection.src))
if connection.dst not in block_names:
raise OpenBoxConfigurationError(
"{dst} in connection's dest block is undefined".format(dst=connection.dst))
connections.append(connection)
return cls(requirements, blocks, connections)
示例2: get_connection
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import from_dict [as 别名]
def get_connection(self, connection_id):
resp_dict = self._root.get('%s/connection/%d/' % (API_VERSION, connection_id), headers=self.headers)
if resp_dict['all']:
return Connection.from_dict(resp_dict['all'][0])
return None
示例3: get_connections
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import from_dict [as 别名]
def get_connections(self):
resp_dict = self._root.get('%s/connection/all' % API_VERSION, headers=self.headers)
connections = [Connection.from_dict(conn_dict) for conn_dict in resp_dict['all']]
return connections