From 32d8afe419c50a6863e3d1fbaf3f8b855a090f68 Mon Sep 17 00:00:00 2001 From: Tomasz Felczyk Date: Sat, 6 Aug 2016 14:39:41 +0200 Subject: [PATCH] _build_sub_requests() accept protos messages as entry in subrequest_list --- pgoapi/rpc_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pgoapi/rpc_api.py b/pgoapi/rpc_api.py index 258dc79f..7afc9af8 100755 --- a/pgoapi/rpc_api.py +++ b/pgoapi/rpc_api.py @@ -33,6 +33,7 @@ import subprocess from google.protobuf import message +from google.protobuf import internal as pb_internal from importlib import import_module @@ -185,7 +186,14 @@ def _build_sub_requests(self, mainrequest, subrequest_list): self.log.debug("Subrequest class: %s", proto_classname) for (key, value) in entry_content.items(): - if isinstance(value, list): + val_type = type(type(value)) + if val_type == pb_internal.python_message.GeneratedProtocolMessageType: + r = getattr(subrequest_extension, key) + for descriptor in value.DESCRIPTOR.fields: + vv = getattr(value, descriptor.name) + if vv is not None: + setattr(r, descriptor.name, vv) + elif isinstance(value, list): self.log.debug("Found list: %s - trying as repeated", key) for i in value: try: