|
|
|
@ -48,6 +48,57 @@ def _interpreter_version_protos_and_services(*args, **kwargs): |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def protos(protobuf_path): |
|
|
|
|
"""Returns a module generated by the indicated .proto file. |
|
|
|
|
|
|
|
|
|
Use this function to retrieve classes corresponding to message |
|
|
|
|
definitions in the .proto file. |
|
|
|
|
|
|
|
|
|
To inspect the contents of the returned module, use the dir function. |
|
|
|
|
For example: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
protos = grpc.protos("foo.proto") |
|
|
|
|
print(dir(protos)) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
The returned module object corresponds to the _pb2.py file generated |
|
|
|
|
by protoc. The path is expected to be relative to an entry on sys.path |
|
|
|
|
and all transitive dependencies of the file should also be resolveable |
|
|
|
|
from an entry on sys.path. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def services(protobuf_path): |
|
|
|
|
"""Returns a module generated by the indicated .proto file. |
|
|
|
|
|
|
|
|
|
Use this function to retrieve classes and functions corresponding to |
|
|
|
|
service definitions in the .proto file, including both stub and servicer |
|
|
|
|
definitions. |
|
|
|
|
|
|
|
|
|
To inspect the contents of the returned module, use the dir function. |
|
|
|
|
For example: |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
services = grpc.services("foo.proto") |
|
|
|
|
print(dir(services)) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
The returned module object corresponds to the _pb2_grpc.py file generated |
|
|
|
|
by protoc. The path is expected to be relative to an entry on sys.path |
|
|
|
|
and all transitive dependencies of the file should also be resolveable |
|
|
|
|
from an entry on sys.path. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def protos_and_services(protobuf_path): |
|
|
|
|
"""Returns a 2-tuple of modules corresponding to protos and services. |
|
|
|
|
|
|
|
|
|
The return value of this function is equivalent to a call to protos and a |
|
|
|
|
call to services. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[0] < 3: |
|
|
|
|
protos = _interpreter_version_protos |
|
|
|
|
services = _interpreter_version_services |
|
|
|
|