module documentation

Helpers for parsing and normalizing gRPC-style method identifiers.

Exception InvalidMethodNameError Raised when a method name does not match expected patterns.
Function fix_name Normalize a fully-qualified gRPC method name to dotted form.
Function service_from_method_name Extract the service name portion from a method identifier.
Variable pattern Regular expression used to parse service and method components.
def fix_name(method_name: str) -> str: (source)

Normalize a fully-qualified gRPC method name to dotted form.

gRPC method names are commonly expressed as /package.Service/Method. This helper strips the leading slash and replaces remaining slashes with dots, yielding package.Service.Method. If the name is already in a non-slashed format it is returned unchanged.

Parameters
method_name:strMethod name to normalize.
Returns
strDotted method identifier.
def service_from_method_name(input_string: str) -> str: (source)

Extract the service name portion from a method identifier.

Accepts gRPC-style method names separated by either / or . and returns the service portion. For example, both /pkg.Service/Method and pkg.Service.Method yield pkg.Service.

Parameters
input_string:strMethod name to parse.
Returns
strService identifier portion of the method name.
Raises
InvalidMethodNameErrorIf the name is malformed or the delimiter usage is inconsistent.

Regular expression used to parse service and method components.