OLD | NEW |
1 # Copyright 2015 The Swarming Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
2 # Use of this source code is governed by the Apache v2.0 license that can be | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """This module facilitates conversion from dictionaries to ProtoRPC messages. | 5 """This module facilitates conversion from dictionaries to ProtoRPC messages. |
6 | 6 |
7 Given a dictionary whose keys' names and values' types comport with the | 7 Given a dictionary whose keys' names and values' types comport with the |
8 fields defined for a protorpc.messages.Message subclass, this module tries to | 8 fields defined for a protorpc.messages.Message subclass, this module tries to |
9 generate a Message instance that corresponds to the provided dictionary. The | 9 generate a Message instance that corresponds to the provided dictionary. The |
10 "normal" use case is for ndb.Models which need to be represented as a | 10 "normal" use case is for ndb.Models which need to be represented as a |
11 ProtoRPC. | 11 ProtoRPC. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 kwargs['costs_usd'].append(entity.cost_usd) | 169 kwargs['costs_usd'].append(entity.cost_usd) |
170 kwargs['properties_hash'] = None | 170 kwargs['properties_hash'] = None |
171 kwargs['tags'] = [] | 171 kwargs['tags'] = [] |
172 kwargs['user'] = None | 172 kwargs['user'] = None |
173 else: | 173 else: |
174 assert entity.__class__ is task_result.TaskResultSummary, entity | 174 assert entity.__class__ is task_result.TaskResultSummary, entity |
175 kwargs['properties_hash'] = ( | 175 kwargs['properties_hash'] = ( |
176 entity.properties_hash.encode('hex') | 176 entity.properties_hash.encode('hex') |
177 if entity.properties_hash else None) | 177 if entity.properties_hash else None) |
178 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) | 178 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) |
OLD | NEW |