@@ -220,22 +220,6 @@ def generate_code(request, response):
220
220
print (f"Writing { output_package_name } " , file = sys .stderr )
221
221
222
222
223
- def lookup_method_input_type (method , types ):
224
- package , name = parse_source_type_name (method .input_type )
225
-
226
- for known_type in types :
227
- if known_type ["type" ] != "Message" :
228
- continue
229
-
230
- # Nested types are currently flattened without dots.
231
- # Todo: keep a fully quantified name in types, that is comparable with method.input_type
232
- if (
233
- package == known_type ["package" ]
234
- and name .replace ("." , "" ) == known_type ["name" ]
235
- ):
236
- return known_type
237
-
238
-
239
223
def read_protobuf_type (item : DescriptorProto , path : List [int ], proto_file , content ):
240
224
input_package_name = content ["input_package" ]
241
225
template_data = content ["template_data" ]
@@ -369,6 +353,22 @@ def read_protobuf_type(item: DescriptorProto, path: List[int], proto_file, conte
369
353
return data
370
354
371
355
356
+ def lookup_method_input_type (method , types ):
357
+ package , name = parse_source_type_name (method .input_type )
358
+
359
+ for known_type in types :
360
+ if known_type ["type" ] != "Message" :
361
+ continue
362
+
363
+ # Nested types are currently flattened without dots.
364
+ # Todo: keep a fully quantified name in types, that is comparable with method.input_type
365
+ if (
366
+ package == known_type ["package" ]
367
+ and name .replace ("." , "" ) == known_type ["name" ]
368
+ ):
369
+ return known_type
370
+
371
+
372
372
def read_protobuf_service (
373
373
service : ServiceDescriptorProto , index , proto_file , content , output_types
374
374
):
@@ -428,7 +428,7 @@ def main():
428
428
request = plugin .CodeGeneratorRequest ()
429
429
request .ParseFromString (data )
430
430
431
- dump_file = os .getenv ("DUMP_FILE " )
431
+ dump_file = os .getenv ("BETTERPROTO_DUMP " )
432
432
if dump_file :
433
433
dump_request (dump_file , request )
434
434
@@ -448,11 +448,11 @@ def main():
448
448
def dump_request (dump_file : str , request : CodeGeneratorRequest ):
449
449
"""
450
450
For developers: Supports running plugin.py standalone so its possible to debug it.
451
- Run protoc (or generate.py) with DUMP_FILE ="yourfile.bin" to write the request to a file.
451
+ Run protoc (or generate.py) with BETTERPROTO_DUMP ="yourfile.bin" to write the request to a file.
452
452
Then run plugin.py from your IDE in debugging mode, and redirect stdin to the file.
453
453
"""
454
454
with open (str (dump_file ), "wb" ) as fh :
455
- sys .stderr .write (f"\033 [31mWriting: { dump_file } \033 [0m\n " )
455
+ sys .stderr .write (f"\033 [31mWriting input from protoc to : { dump_file } \033 [0m\n " )
456
456
fh .write (request .SerializeToString ())
457
457
458
458
0 commit comments