本文整理汇总了Python中models.Branch.get方法的典型用法代码示例。如果您正苦于以下问题:Python Branch.get方法的具体用法?Python Branch.get怎么用?Python Branch.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Branch
的用法示例。
在下文中一共展示了Branch.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import Branch [as 别名]
# 或者: from models.Branch import get [as 别名]
def __init__(self):
# FIXME: This function is massive. Break it up
self._test_map = {}
platform_id_map = {}
branch_id_map = {}
for test in Test.all():
if test.hidden:
continue
branch_ids = [Branch.get(branch_key).id for branch_key in test.branches]
platform_ids = [Platform.get(platform_key).id for platform_key in test.platforms]
self._test_map[test.id] = {
'name': test.name,
'branchIds': branch_ids,
'platformIds': platform_ids,
}
for platform_id in platform_ids:
platform_id_map.setdefault(platform_id, {'tests': [], 'branches': []})
platform_id_map[platform_id]['tests'].append(test.id)
platform_id_map[platform_id]['branches'] += branch_ids
for branch_id in branch_ids:
branch_id_map.setdefault(branch_id, {'tests': [], 'platforms': []})
branch_id_map[branch_id]['tests'].append(test.id)
branch_id_map[branch_id]['platforms'] += platform_ids
self._platform_map = {}
for platform in Platform.all():
if platform.id not in platform_id_map:
continue
if platform.hidden:
for test_id in platform_id_map[platform.id]['tests']:
self._test_map[test_id]['platformIds'].remove(platform.id)
for branch_id in platform_id_map[platform.id]['branches']:
branch_id_map[branch_id]['platforms'].remove(platform.id)
continue
self._platform_map[platform.id] = {
'name': platform.name,
'testIds': list(set(platform_id_map[platform.id]['tests'])),
'branchIds': list(set(platform_id_map[platform.id]['branches'])),
}
self._branch_map = {}
for branch in Branch.all():
if branch.id not in branch_id_map:
continue
self._branch_map[branch.id] = {
'name': branch.name,
'testIds': list(set(branch_id_map[branch.id]['tests'])),
'platformIds': list(set(branch_id_map[branch.id]['platforms'])),
}