本文整理汇总了Python中models.Platform.get方法的典型用法代码示例。如果您正苦于以下问题:Python Platform.get方法的具体用法?Python Platform.get怎么用?Python Platform.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Platform
的用法示例。
在下文中一共展示了Platform.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from models import Platform [as 别名]
# 或者: from models.Platform 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'])),
}
示例2: get
# 需要导入模块: from models import Platform [as 别名]
# 或者: from models.Platform import get [as 别名]
def get(self):
self.response.headers['Content-Type'] = 'text/plain; charset=utf-8';
cache = memcache.get('manifest')
if cache:
self.response.out.write(cache)
return
testMap = {}
platformIdMap = {}
branchIdMap = {}
for test in Test.all():
branchIds = [Branch.get(branchKey).id for branchKey in test.branches]
platformIds = [Platform.get(platformKey).id for platformKey in test.platforms]
testMap[test.id] = {
'name': test.name,
'branchIds': branchIds,
'platformIds': platformIds,
}
for platformId in platformIds:
platformIdMap.setdefault(platformId, {'tests': [], 'branches': []})
platformIdMap[platformId]['tests'].append(test.id)
platformIdMap[platformId]['branches'] += branchIds
for branchId in branchIds:
branchIdMap.setdefault(branchId, {'tests': [], 'platforms': []})
branchIdMap[branchId]['tests'].append(test.id)
branchIdMap[branchId]['platforms'] += platformIds
platformMap = {}
for platform in Platform.all():
if platform.id not in platformIdMap:
continue
platformMap[platform.id] = {
'name': platform.name,
'testIds': list(set(platformIdMap[platform.id]['tests'])),
'branchIds': list(set(platformIdMap[platform.id]['branches'])),
}
branchMap = {}
for branch in Branch.all():
if branch.id not in branchIdMap:
continue
branchMap[branch.id] = {
'name': branch.name,
'testIds': list(set(branchIdMap[branch.id]['tests'])),
'platformIds': list(set(branchIdMap[branch.id]['platforms'])),
}
result = json.dumps({'testMap': testMap, 'platformMap': platformMap, 'branchMap': branchMap})
self.response.out.write(result)
memcache.add('manifest', result)