aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/python_generator.cc
diff options
context:
space:
mode:
authorGravatar Leifur Halldor Asgeirsson <lasgeirsson@zerofail.com>2016-03-08 13:18:14 -0500
committerGravatar Leif Halldor Asgeirsson <leifur@leifur.ca>2016-03-18 16:37:44 -0400
commit798eeda24e29c24bcd06adef521853ff3db6dc86 (patch)
treeda9af2d04060f4a7ace12199961924151f020d10 /src/compiler/python_generator.cc
parent79787471985c8b1403b82a3f3df225496c0fd7e1 (diff)
python 2/3 compatible abstract servicers/stubs
Diffstat (limited to 'src/compiler/python_generator.cc')
-rw-r--r--src/compiler/python_generator.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index 4fd5dfbecb..5a2ecce1d4 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -190,11 +190,10 @@ bool PrintBetaServicer(const ServiceDescriptor* service,
"Documentation", doc,
});
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);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
- out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) {
auto meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ?
@@ -219,11 +218,10 @@ bool PrintBetaStub(const ServiceDescriptor* service,
"Documentation", doc,
});
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);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
- out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ?
@@ -449,6 +447,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
bool PrintPreamble(const FileDescriptor* file,
const GeneratorConfiguration& config, Printer* out) {
out->Print("import abc\n");
+ out->Print("import six\n");
out->Print("from $Package$ import implementations as beta_implementations\n",
"Package", config.beta_package_root);
out->Print("from grpc.framework.common import cardinality\n");