diff options
author | heretic <heretic@yandex-team.ru> | 2022-02-10 16:45:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:46 +0300 |
commit | 81eddc8c0b55990194e112b02d127b87d54164a9 (patch) | |
tree | 9142afc54d335ea52910662635b898e79e192e49 /contrib/libs/grpc/src/python/grpcio_reflection | |
parent | 397cbe258b9e064f49c4ca575279f02f39fef76e (diff) | |
download | ydb-81eddc8c0b55990194e112b02d127b87d54164a9.tar.gz |
Restoring authorship annotation for <heretic@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/python/grpcio_reflection')
7 files changed, 272 insertions, 272 deletions
diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt b/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt index 26ef8a892c..33706ec084 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt +++ b/contrib/libs/grpc/src/python/grpcio_reflection/.yandex_meta/licenses.list.txt @@ -1,28 +1,28 @@ -====================Apache-2.0==================== - license='Apache License 2.0', - - -====================Apache-2.0==================== - 'License :: OSI Approved :: Apache Software License', - - -====================Apache-2.0==================== -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -====================COPYRIGHT==================== - * Copyright 2016 gRPC authors. - - -====================COPYRIGHT==================== - * Copyright 2020 gRPC authors. +====================Apache-2.0==================== + license='Apache License 2.0', + + +====================Apache-2.0==================== + 'License :: OSI Approved :: Apache Software License', + + +====================Apache-2.0==================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +====================COPYRIGHT==================== + * Copyright 2016 gRPC authors. + + +====================COPYRIGHT==================== + * Copyright 2020 gRPC authors. diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py index 3a9cc42568..fb567fc09f 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py +++ b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_async.py @@ -1,57 +1,57 @@ -# Copyright 2020 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""The AsyncIO version of the reflection servicer.""" - -from typing import AsyncIterable - -import grpc - -from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from grpc_reflection.v1alpha._base import BaseReflectionServicer - - -class ReflectionServicer(BaseReflectionServicer): - """Servicer handling RPCs for service statuses.""" - - async def ServerReflectionInfo( - self, request_iterator: AsyncIterable[ - _reflection_pb2.ServerReflectionRequest], unused_context - ) -> AsyncIterable[_reflection_pb2.ServerReflectionResponse]: - async for request in request_iterator: - if request.HasField('file_by_filename'): - yield self._file_by_filename(request.file_by_filename) - elif request.HasField('file_containing_symbol'): - yield self._file_containing_symbol( - request.file_containing_symbol) - elif request.HasField('file_containing_extension'): - yield self._file_containing_extension( - request.file_containing_extension.containing_type, - request.file_containing_extension.extension_number) - elif request.HasField('all_extension_numbers_of_type'): - yield self._all_extension_numbers_of_type( - request.all_extension_numbers_of_type) - elif request.HasField('list_services'): - yield self._list_services() - else: - yield _reflection_pb2.ServerReflectionResponse( - error_response=_reflection_pb2.ErrorResponse( - error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], - error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. - encode(), - )) - - -__all__ = [ - "ReflectionServicer", -] +# Copyright 2020 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The AsyncIO version of the reflection servicer.""" + +from typing import AsyncIterable + +import grpc + +from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 +from grpc_reflection.v1alpha._base import BaseReflectionServicer + + +class ReflectionServicer(BaseReflectionServicer): + """Servicer handling RPCs for service statuses.""" + + async def ServerReflectionInfo( + self, request_iterator: AsyncIterable[ + _reflection_pb2.ServerReflectionRequest], unused_context + ) -> AsyncIterable[_reflection_pb2.ServerReflectionResponse]: + async for request in request_iterator: + if request.HasField('file_by_filename'): + yield self._file_by_filename(request.file_by_filename) + elif request.HasField('file_containing_symbol'): + yield self._file_containing_symbol( + request.file_containing_symbol) + elif request.HasField('file_containing_extension'): + yield self._file_containing_extension( + request.file_containing_extension.containing_type, + request.file_containing_extension.extension_number) + elif request.HasField('all_extension_numbers_of_type'): + yield self._all_extension_numbers_of_type( + request.all_extension_numbers_of_type) + elif request.HasField('list_services'): + yield self._list_services() + else: + yield _reflection_pb2.ServerReflectionResponse( + error_response=_reflection_pb2.ErrorResponse( + error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], + error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. + encode(), + )) + + +__all__ = [ + "ReflectionServicer", +] diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py index b67c7ff2f5..677dca9858 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py +++ b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/_base.py @@ -1,110 +1,110 @@ -# Copyright 2020 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Base implementation of reflection servicer.""" - -import grpc -from google.protobuf import descriptor_pb2 -from google.protobuf import descriptor_pool - -from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 -from src.proto.grpc.reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc - -_POOL = descriptor_pool.Default() - - -def _not_found_error(): - return _reflection_pb2.ServerReflectionResponse( - error_response=_reflection_pb2.ErrorResponse( - error_code=grpc.StatusCode.NOT_FOUND.value[0], - error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), - )) - - -def _file_descriptor_response(descriptor): - proto = descriptor_pb2.FileDescriptorProto() - descriptor.CopyToProto(proto) - serialized_proto = proto.SerializeToString() - return _reflection_pb2.ServerReflectionResponse( - file_descriptor_response=_reflection_pb2.FileDescriptorResponse( - file_descriptor_proto=(serialized_proto,)),) - - -class BaseReflectionServicer(_reflection_pb2_grpc.ServerReflectionServicer): - """Base class for reflection servicer.""" - - def __init__(self, service_names, pool=None): - """Constructor. - - Args: - service_names: Iterable of fully-qualified service names available. - pool: An optional DescriptorPool instance. - """ - self._service_names = tuple(sorted(service_names)) - self._pool = _POOL if pool is None else pool - - def _file_by_filename(self, filename): - try: - descriptor = self._pool.FindFileByName(filename) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _file_containing_symbol(self, fully_qualified_name): - try: - descriptor = self._pool.FindFileContainingSymbol( - fully_qualified_name) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _file_containing_extension(self, containing_type, extension_number): - try: - message_descriptor = self._pool.FindMessageTypeByName( - containing_type) - extension_descriptor = self._pool.FindExtensionByNumber( - message_descriptor, extension_number) - descriptor = self._pool.FindFileContainingSymbol( - extension_descriptor.full_name) - except KeyError: - return _not_found_error() - else: - return _file_descriptor_response(descriptor) - - def _all_extension_numbers_of_type(self, containing_type): - try: - message_descriptor = self._pool.FindMessageTypeByName( - containing_type) - extension_numbers = tuple( - sorted(extension.number for extension in - self._pool.FindAllExtensions(message_descriptor))) - except KeyError: - return _not_found_error() - else: - return _reflection_pb2.ServerReflectionResponse( - all_extension_numbers_response=_reflection_pb2. - ExtensionNumberResponse( - base_type_name=message_descriptor.full_name, - extension_number=extension_numbers)) - - def _list_services(self): - return _reflection_pb2.ServerReflectionResponse( - list_services_response=_reflection_pb2.ListServiceResponse(service=[ - _reflection_pb2.ServiceResponse(name=service_name) - for service_name in self._service_names - ])) - - -__all__ = ['BaseReflectionServicer'] +# Copyright 2020 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Base implementation of reflection servicer.""" + +import grpc +from google.protobuf import descriptor_pb2 +from google.protobuf import descriptor_pool + +from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 +from src.proto.grpc.reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc + +_POOL = descriptor_pool.Default() + + +def _not_found_error(): + return _reflection_pb2.ServerReflectionResponse( + error_response=_reflection_pb2.ErrorResponse( + error_code=grpc.StatusCode.NOT_FOUND.value[0], + error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), + )) + + +def _file_descriptor_response(descriptor): + proto = descriptor_pb2.FileDescriptorProto() + descriptor.CopyToProto(proto) + serialized_proto = proto.SerializeToString() + return _reflection_pb2.ServerReflectionResponse( + file_descriptor_response=_reflection_pb2.FileDescriptorResponse( + file_descriptor_proto=(serialized_proto,)),) + + +class BaseReflectionServicer(_reflection_pb2_grpc.ServerReflectionServicer): + """Base class for reflection servicer.""" + + def __init__(self, service_names, pool=None): + """Constructor. + + Args: + service_names: Iterable of fully-qualified service names available. + pool: An optional DescriptorPool instance. + """ + self._service_names = tuple(sorted(service_names)) + self._pool = _POOL if pool is None else pool + + def _file_by_filename(self, filename): + try: + descriptor = self._pool.FindFileByName(filename) + except KeyError: + return _not_found_error() + else: + return _file_descriptor_response(descriptor) + + def _file_containing_symbol(self, fully_qualified_name): + try: + descriptor = self._pool.FindFileContainingSymbol( + fully_qualified_name) + except KeyError: + return _not_found_error() + else: + return _file_descriptor_response(descriptor) + + def _file_containing_extension(self, containing_type, extension_number): + try: + message_descriptor = self._pool.FindMessageTypeByName( + containing_type) + extension_descriptor = self._pool.FindExtensionByNumber( + message_descriptor, extension_number) + descriptor = self._pool.FindFileContainingSymbol( + extension_descriptor.full_name) + except KeyError: + return _not_found_error() + else: + return _file_descriptor_response(descriptor) + + def _all_extension_numbers_of_type(self, containing_type): + try: + message_descriptor = self._pool.FindMessageTypeByName( + containing_type) + extension_numbers = tuple( + sorted(extension.number for extension in + self._pool.FindAllExtensions(message_descriptor))) + except KeyError: + return _not_found_error() + else: + return _reflection_pb2.ServerReflectionResponse( + all_extension_numbers_response=_reflection_pb2. + ExtensionNumberResponse( + base_type_name=message_descriptor.full_name, + extension_number=extension_numbers)) + + def _list_services(self): + return _reflection_pb2.ServerReflectionResponse( + list_services_response=_reflection_pb2.ListServiceResponse(service=[ + _reflection_pb2.ServiceResponse(name=service_name) + for service_name in self._service_names + ])) + + +__all__ = ['BaseReflectionServicer'] diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index 70d1b7ecf2..b302cea241 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -13,19 +13,19 @@ # limitations under the License. """Reference implementation for reflection in gRPC Python.""" -import sys +import sys import grpc from src.proto.grpc.reflection.v1alpha import reflection_pb2 as _reflection_pb2 from src.proto.grpc.reflection.v1alpha import reflection_pb2_grpc as _reflection_pb2_grpc -from grpc_reflection.v1alpha._base import BaseReflectionServicer - +from grpc_reflection.v1alpha._base import BaseReflectionServicer + SERVICE_NAME = _reflection_pb2.DESCRIPTOR.services_by_name[ 'ServerReflection'].full_name -class ReflectionServicer(BaseReflectionServicer): +class ReflectionServicer(BaseReflectionServicer): """Servicer handling RPCs for service statuses.""" def ServerReflectionInfo(self, request_iterator, context): @@ -49,50 +49,50 @@ class ReflectionServicer(BaseReflectionServicer): yield _reflection_pb2.ServerReflectionResponse( error_response=_reflection_pb2.ErrorResponse( error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], - error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. - encode(), + error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1]. + encode(), )) -_enable_server_reflection_doc = """Enables server reflection on a server. - -Args: - service_names: Iterable of fully-qualified service names available. - server: grpc.Server to which reflection service will be added. - pool: DescriptorPool object to use (descriptor_pool.Default() if None). -""" - -if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: - # Exposes AsyncReflectionServicer as public API. - from . import _async as aio - from grpc.experimental import aio as grpc_aio # pylint: disable=ungrouped-imports - - def enable_server_reflection(service_names, server, pool=None): - if isinstance(server, grpc_aio.Server): - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - aio.ReflectionServicer(service_names, pool=pool), server) - else: - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - ReflectionServicer(service_names, pool=pool), server) - - enable_server_reflection.__doc__ = _enable_server_reflection_doc - - __all__ = [ - "SERVICE_NAME", - "ReflectionServicer", - "enable_server_reflection", - "aio", - ] -else: - - def enable_server_reflection(service_names, server, pool=None): - _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( - ReflectionServicer(service_names, pool=pool), server) - - enable_server_reflection.__doc__ = _enable_server_reflection_doc - - __all__ = [ - "SERVICE_NAME", - "ReflectionServicer", - "enable_server_reflection", - ] +_enable_server_reflection_doc = """Enables server reflection on a server. + +Args: + service_names: Iterable of fully-qualified service names available. + server: grpc.Server to which reflection service will be added. + pool: DescriptorPool object to use (descriptor_pool.Default() if None). +""" + +if sys.version_info[0] >= 3 and sys.version_info[1] >= 6: + # Exposes AsyncReflectionServicer as public API. + from . import _async as aio + from grpc.experimental import aio as grpc_aio # pylint: disable=ungrouped-imports + + def enable_server_reflection(service_names, server, pool=None): + if isinstance(server, grpc_aio.Server): + _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( + aio.ReflectionServicer(service_names, pool=pool), server) + else: + _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( + ReflectionServicer(service_names, pool=pool), server) + + enable_server_reflection.__doc__ = _enable_server_reflection_doc + + __all__ = [ + "SERVICE_NAME", + "ReflectionServicer", + "enable_server_reflection", + "aio", + ] +else: + + def enable_server_reflection(service_names, server, pool=None): + _reflection_pb2_grpc.add_ServerReflectionServicer_to_server( + ReflectionServicer(service_names, pool=pool), server) + + enable_server_reflection.__doc__ = _enable_server_reflection_doc + + __all__ = [ + "SERVICE_NAME", + "ReflectionServicer", + "enable_server_reflection", + ] diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py index 5ac147c869..676511118a 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py +++ b/contrib/libs/grpc/src/python/grpcio_reflection/grpc_version.py @@ -14,4 +14,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION = '1.33.2' +VERSION = '1.33.2' diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/setup.py b/contrib/libs/grpc/src/python/grpcio_reflection/setup.py index 7a5b060f9c..2d0a3fcdaa 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/setup.py +++ b/contrib/libs/grpc/src/python/grpcio_reflection/setup.py @@ -55,7 +55,7 @@ CLASSIFIERS = [ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.9', 'License :: OSI Approved :: Apache Software License', ] @@ -71,8 +71,8 @@ INSTALL_REQUIRES = ( try: import reflection_commands as _reflection_commands # we are in the build environment, otherwise the above import fails - SETUP_REQUIRES = ('grpcio-tools=={version}'.format( - version=grpc_version.VERSION),) + SETUP_REQUIRES = ('grpcio-tools=={version}'.format( + version=grpc_version.VERSION),) COMMAND_CLASS = { # Run preprocess from the repository *before* doing any packaging! 'preprocess': _reflection_commands.Preprocess, @@ -86,17 +86,17 @@ except ImportError: 'build_package_protos': _NoOpCommand, } -setuptools.setup(name='grpcio-reflection', - version=grpc_version.VERSION, - license='Apache License 2.0', - description='Standard Protobuf Reflection Service for gRPC', - long_description=open(_README_PATH, 'r').read(), - author='The gRPC Authors', - author_email='grpc-io@googlegroups.com', - classifiers=CLASSIFIERS, - url='https://grpc.io', - package_dir=PACKAGE_DIRECTORIES, - packages=setuptools.find_packages('.'), - install_requires=INSTALL_REQUIRES, - setup_requires=SETUP_REQUIRES, - cmdclass=COMMAND_CLASS) +setuptools.setup(name='grpcio-reflection', + version=grpc_version.VERSION, + license='Apache License 2.0', + description='Standard Protobuf Reflection Service for gRPC', + long_description=open(_README_PATH, 'r').read(), + author='The gRPC Authors', + author_email='grpc-io@googlegroups.com', + classifiers=CLASSIFIERS, + url='https://grpc.io', + package_dir=PACKAGE_DIRECTORIES, + packages=setuptools.find_packages('.'), + install_requires=INSTALL_REQUIRES, + setup_requires=SETUP_REQUIRES, + cmdclass=COMMAND_CLASS) diff --git a/contrib/libs/grpc/src/python/grpcio_reflection/ya.make b/contrib/libs/grpc/src/python/grpcio_reflection/ya.make index 34233d3fad..c0f7d61dcc 100644 --- a/contrib/libs/grpc/src/python/grpcio_reflection/ya.make +++ b/contrib/libs/grpc/src/python/grpcio_reflection/ya.make @@ -2,8 +2,8 @@ PY23_LIBRARY() LICENSE(Apache-2.0) -LICENSE_TEXTS(.yandex_meta/licenses.list.txt) - +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + OWNER( akastornov dvshkurko @@ -25,7 +25,7 @@ IF (PYTHON2) ENDIF() ADDINCL( - ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc + ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc contrib/libs/grpc contrib/libs/grpc/include ) @@ -43,15 +43,15 @@ PY_SRCS( TOP_LEVEL grpc_reflection/__init__.py grpc_reflection/v1alpha/__init__.py - grpc_reflection/v1alpha/_base.py + grpc_reflection/v1alpha/_base.py grpc_reflection/v1alpha/reflection.py ) -IF (PYTHON3) - PY_SRCS( - TOP_LEVEL - grpc_reflection/v1alpha/_async.py - ) -ENDIF() - +IF (PYTHON3) + PY_SRCS( + TOP_LEVEL + grpc_reflection/v1alpha/_async.py + ) +ENDIF() + END() |