Skip to content
Snippets Groups Projects
Commit 798eeda2 authored by Leifur Halldor Asgeirsson's avatar Leifur Halldor Asgeirsson Committed by Leif Halldor Asgeirsson
Browse files

python 2/3 compatible abstract servicers/stubs

parent 79787471
No related branches found
No related tags found
No related merge requests found
...@@ -190,11 +190,10 @@ bool PrintBetaServicer(const ServiceDescriptor* service, ...@@ -190,11 +190,10 @@ bool PrintBetaServicer(const ServiceDescriptor* service,
"Documentation", doc, "Documentation", doc,
}); });
out->Print("\n"); out->Print("\n");
out->Print(dict, "class Beta$Service$Servicer(object):\n"); out->Print(dict, "class Beta$Service$Servicer(six.with_metaclass(abc.ABCMeta, object)):\n");
{ {
IndentScope raii_class_indent(out); IndentScope raii_class_indent(out);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n"); out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
auto meth = service->method(i); auto meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ? grpc::string arg_name = meth->client_streaming() ?
...@@ -219,11 +218,10 @@ bool PrintBetaStub(const ServiceDescriptor* service, ...@@ -219,11 +218,10 @@ bool PrintBetaStub(const ServiceDescriptor* service,
"Documentation", doc, "Documentation", doc,
}); });
out->Print("\n"); out->Print("\n");
out->Print(dict, "class Beta$Service$Stub(object):\n"); out->Print(dict, "class Beta$Service$Stub(six.with_metaclass(abc.ABCMeta, object)):\n");
{ {
IndentScope raii_class_indent(out); IndentScope raii_class_indent(out);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n"); out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) { for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* meth = service->method(i); const MethodDescriptor* meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ? grpc::string arg_name = meth->client_streaming() ?
...@@ -449,6 +447,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name, ...@@ -449,6 +447,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
bool PrintPreamble(const FileDescriptor* file, bool PrintPreamble(const FileDescriptor* file,
const GeneratorConfiguration& config, Printer* out) { const GeneratorConfiguration& config, Printer* out) {
out->Print("import abc\n"); out->Print("import abc\n");
out->Print("import six\n");
out->Print("from $Package$ import implementations as beta_implementations\n", out->Print("from $Package$ import implementations as beta_implementations\n",
"Package", config.beta_package_root); "Package", config.beta_package_root);
out->Print("from grpc.framework.common import cardinality\n"); out->Print("from grpc.framework.common import cardinality\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment