Forráskód Böngészése

Returned print_indent and print_outdent back to printservicestub and printserviceclass in python generator

Krishna 10 éve
szülő
commit
22f96a713c

+ 8 - 5
src/google/protobuf/compiler/python/python_generator.cc

@@ -581,17 +581,14 @@ void Generator::PrintServiceDescriptor(
 }
 
 
-void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const {	
-  printer_->Indent();
+void Generator::PrintDescriptorKeyAndModuleName(const ServiceDescriptor& descriptor) const {	  
   printer_->Print(
       "$descriptor_key$ = $descriptor_name$,\n",
       "descriptor_key", kDescriptorKey,
       "descriptor_name", ModuleLevelServiceDescriptorName(descriptor));
   printer_->Print(
       "__module__ = '$module_name$'\n",
-      "module_name", ModuleName(file_->name()));
-  printer_->Print("))\n\n");
-  printer_->Outdent();
+      "module_name", ModuleName(file_->name())); 
 }
 
 void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
@@ -599,7 +596,10 @@ void Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {
   printer_->Print("$class_name$ = service_reflection.GeneratedServiceType("
                   "'$class_name$', (_service.Service,), dict(\n",
                   "class_name", descriptor.name());
+  printer_->Indent();
   Generator::PrintDescriptorKeyAndModuleName(descriptor);
+  printer_->Print("))\n\n");
+  printer_->Outdent();
 }
 
 void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
@@ -608,7 +608,10 @@ void Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {
                   "service_reflection.GeneratedServiceStubType("
                   "'$class_name$_Stub', ($class_name$,), dict(\n",
                   "class_name", descriptor.name());
+  printer_->Indent();
   Generator::PrintDescriptorKeyAndModuleName(descriptor);
+  printer_->Print("))\n\n");
+  printer_->Outdent();
 }
 
 // Prints statement assigning ModuleLevelDescriptorName(message_descriptor)