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


Python Connection.from_dict方法代码示例

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

示例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
开发者ID:2013Commons,项目名称:hue,代码行数:7,代码来源:base.py

示例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
开发者ID:2013Commons,项目名称:hue,代码行数:6,代码来源:base.py


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