Reverted introduction of the new file extension

This commit is contained in:
Vladimir Magamedov 2020-06-03 21:09:27 +03:00
parent 18c261e7eb
commit a74bcb0678
24 changed files with 27 additions and 34 deletions

View File

@ -4,8 +4,7 @@ __default__:
@echo "Please specify a target to make"
GEN=python3 -m grpc_tools.protoc -I. --python_out=. --python_grpc_out=. --mypy_out=.
GEN2=python3 -m grpc_tools.protoc -I. --python_out=. --python_grpclib_out=. --mypy_out=.
GENERATED=*{_pb2.py,_grpc.py,_grpclib.py,.pyi}
GENERATED=*{_pb2.py,_grpc.py,.pyi}
clean:
rm -f grpclib/health/v1/$(GENERATED)
@ -18,14 +17,14 @@ clean:
rm -f tests/$(GENERATED)
proto: clean
$(GEN2) grpclib/health/v1/health.proto
$(GEN2) grpclib/reflection/v1/reflection.proto
$(GEN2) grpclib/reflection/v1alpha/reflection.proto
$(GEN2) grpclib/channelz/v1/channelz.proto
$(GEN) grpclib/health/v1/health.proto
$(GEN) grpclib/reflection/v1/reflection.proto
$(GEN) grpclib/reflection/v1alpha/reflection.proto
$(GEN) grpclib/channelz/v1/channelz.proto
cd examples && $(GEN) --grpc_python_out=. helloworld/helloworld.proto
cd examples && $(GEN) streaming/helloworld.proto
cd examples && $(GEN) multiproc/primes.proto
cd tests && $(GEN2) dummy.proto
cd tests && $(GEN) dummy.proto
release: proto
./scripts/release_check.sh

View File

@ -7,7 +7,7 @@ from pathlib import Path
from grpclib.client import Channel
from grpclib.health.v1.health_pb2 import HealthCheckRequest
from grpclib.health.v1.health_grpclib import HealthStub
from grpclib.health.v1.health_grpc import HealthStub
DIR = Path(__file__).parent.joinpath('keys')

View File

@ -9,7 +9,7 @@ from .v1.channelz_pb2 import GetServerSocketsRequest, GetServerSocketsResponse
from .v1.channelz_pb2 import GetChannelRequest, GetChannelResponse
from .v1.channelz_pb2 import GetSubchannelRequest, GetSubchannelResponse
from .v1.channelz_pb2 import GetSocketRequest, GetSocketResponse
from .v1.channelz_grpclib import ChannelzBase
from .v1.channelz_grpc import ChannelzBase
class Channelz(ChannelzBase):

View File

@ -8,7 +8,7 @@ from ..utils import _service_name
from ..server import Stream
from .v1.health_pb2 import HealthCheckRequest, HealthCheckResponse
from .v1.health_grpclib import HealthBase
from .v1.health_grpc import HealthBase
if TYPE_CHECKING:

View File

@ -176,9 +176,8 @@ def _proto2pb2_module_name(proto_file_path: str) -> str:
return _base_module_name(proto_file_path) + "_pb2"
def _proto2grpc_module_name(proto_file_path: str, *, legacy: bool) -> str:
suffix = "_grpc" if legacy else '_grpclib'
return _base_module_name(proto_file_path) + suffix
def _proto2grpc_module_name(proto_file_path: str) -> str:
return _base_module_name(proto_file_path) + "_grpc"
def _type_names(
@ -207,7 +206,7 @@ def _type_names(
parents.pop()
def main(*, _legacy: bool = False) -> None:
def main() -> None:
with os.fdopen(sys.stdin.fileno(), 'rb') as inp:
request = CodeGeneratorRequest.FromString(inp.read())
@ -239,7 +238,7 @@ def main(*, _legacy: bool = False) -> None:
methods=methods))
file = response.file.add()
module_name = _proto2grpc_module_name(file_to_generate, legacy=_legacy)
module_name = _proto2grpc_module_name(file_to_generate)
file.name = module_name.replace(".", "/") + ".py"
file.content = render(
proto_file=proto_file.name,
@ -250,7 +249,3 @@ def main(*, _legacy: bool = False) -> None:
with os.fdopen(sys.stdout.fileno(), 'wb') as out:
out.write(response.SerializeToString())
def main_legacy() -> None:
main(_legacy=True)

View File

@ -28,7 +28,7 @@ from .v1alpha.reflection_pb2 import ServerReflectionResponse
from .v1alpha.reflection_pb2 import ErrorResponse, ListServiceResponse
from .v1alpha.reflection_pb2 import ServiceResponse, ExtensionNumberResponse
from .v1alpha.reflection_pb2 import FileDescriptorResponse
from .v1alpha.reflection_grpclib import ServerReflectionBase
from .v1alpha.reflection_grpc import ServerReflectionBase
class ServerReflection(ServerReflectionBase):

View File

@ -28,7 +28,7 @@ from .v1.reflection_pb2 import ServerReflectionRequest, ServerReflectionResponse
from .v1.reflection_pb2 import ErrorResponse, ListServiceResponse
from .v1.reflection_pb2 import ServiceResponse, ExtensionNumberResponse
from .v1.reflection_pb2 import FileDescriptorResponse
from .v1.reflection_grpclib import ServerReflectionBase
from .v1.reflection_grpc import ServerReflectionBase
from ._deprecated import ServerReflection as _ServerReflectionV1Alpha

View File

@ -18,7 +18,7 @@ skip_covered = true
sort = miss
[flake8]
exclude = .git,.tox,env,*_pb2.py,*_grpc.py,*_grpclib.py
exclude = .git,.tox,env,*_pb2.py,*_grpc.py
max_line_length = 80
[mypy]

View File

@ -34,8 +34,7 @@ setup(
],
entry_points={
'console_scripts': [
'protoc-gen-python_grpc=grpclib.plugin.main:main_legacy',
'protoc-gen-python_grpclib=grpclib.plugin.main:main',
'protoc-gen-python_grpc=grpclib.plugin.main:main',
],
},
classifiers=[

View File

@ -7,7 +7,7 @@ from grpclib.client import Channel
from grpclib.testing import ChannelFor
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceStub
from dummy_grpc import DummyServiceStub
from test_functional import DummyService

View File

@ -9,7 +9,7 @@ from grpclib.testing import ChannelFor
from grpclib.exceptions import GRPCError
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceStub, DummyServiceBase
from dummy_grpc import DummyServiceStub, DummyServiceBase
class DummyService(DummyServiceBase):

View File

@ -8,7 +8,7 @@ from grpclib.client import Channel
from grpclib.server import Server
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceBase, DummyServiceStub
from dummy_grpc import DummyServiceBase, DummyServiceStub
class DummyService(DummyServiceBase):

View File

@ -9,7 +9,7 @@ from grpclib.exceptions import GRPCError
from grpclib.health.check import ServiceCheck, ServiceStatus
from grpclib.health.service import Health
from grpclib.health.v1.health_pb2 import HealthCheckRequest, HealthCheckResponse
from grpclib.health.v1.health_grpclib import HealthStub
from grpclib.health.v1.health_grpc import HealthStub
class Check:

View File

@ -10,7 +10,7 @@ from grpclib.exceptions import GRPCError
from conn import ClientServer
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceBase, DummyServiceStub
from dummy_grpc import DummyServiceBase, DummyServiceStub
class DummyService(DummyServiceBase):

View File

@ -10,7 +10,7 @@ from grpclib.reflection.service import ServerReflection
from grpclib.reflection.v1.reflection_pb2 import ServerReflectionRequest
from grpclib.reflection.v1.reflection_pb2 import ServerReflectionResponse
from grpclib.reflection.v1.reflection_pb2 import ErrorResponse
from grpclib.reflection.v1.reflection_grpclib import ServerReflectionStub
from grpclib.reflection.v1.reflection_grpc import ServerReflectionStub
from dummy_pb2 import DESCRIPTOR
from test_functional import DummyService

View File

@ -9,7 +9,7 @@ from grpclib.exceptions import GRPCError
from grpclib.testing import ChannelFor
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceStub, DummyServiceBase
from dummy_grpc import DummyServiceStub, DummyServiceBase
class DummyService(DummyServiceBase):

View File

@ -10,7 +10,7 @@ from grpclib.testing import ChannelFor
from grpclib.exceptions import GRPCError
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceBase, DummyServiceStub
from dummy_grpc import DummyServiceBase, DummyServiceStub
def _is_recent(value):

View File

@ -8,7 +8,7 @@ from grpclib.exceptions import GRPCError
from grpclib.encoding.proto import ProtoCodec, ProtoStatusDetailsCodec
from dummy_pb2 import DummyRequest
from dummy_grpclib import DummyServiceStub
from dummy_grpc import DummyServiceStub
from test_functional import DummyService

View File

@ -3,7 +3,7 @@ import pytest
from grpclib.testing import ChannelFor
from dummy_pb2 import DummyRequest, DummyReply
from dummy_grpclib import DummyServiceStub
from dummy_grpc import DummyServiceStub
from test_functional import DummyService