| OLD | NEW |
| 1 # Copyright 2015 The LUCI 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 under the Apache License, Version 2.0 |
| 3 # found in the LICENSE file. | 3 # that can be 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. |
| 12 """ | 12 """ |
| 13 | 13 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 kwargs['costs_usd'].append(entity.cost_usd) | 223 kwargs['costs_usd'].append(entity.cost_usd) |
| 224 kwargs['properties_hash'] = None | 224 kwargs['properties_hash'] = None |
| 225 kwargs['tags'] = [] | 225 kwargs['tags'] = [] |
| 226 kwargs['user'] = None | 226 kwargs['user'] = None |
| 227 else: | 227 else: |
| 228 assert entity.__class__ is task_result.TaskResultSummary, entity | 228 assert entity.__class__ is task_result.TaskResultSummary, entity |
| 229 kwargs['properties_hash'] = ( | 229 kwargs['properties_hash'] = ( |
| 230 entity.properties_hash.encode('hex') | 230 entity.properties_hash.encode('hex') |
| 231 if entity.properties_hash else None) | 231 if entity.properties_hash else None) |
| 232 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) | 232 return _ndb_to_rpc(swarming_rpcs.TaskResult, entity, **kwargs) |
| OLD | NEW |