|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from typing import Set |
|
import collections |
|
|
|
|
|
_ProtoModule = collections.namedtuple( |
|
"ProtoModule", |
|
["package", "marshal", "manifest"], |
|
) |
|
|
|
|
|
def define_module( |
|
*, package: str, marshal: str = None, manifest: Set[str] = frozenset() |
|
) -> _ProtoModule: |
|
"""Define a protocol buffers module. |
|
|
|
The settings defined here are used for all protobuf messages |
|
declared in the module of the given name. |
|
|
|
Args: |
|
package (str): The proto package name. |
|
marshal (str): The name of the marshal to use. It is recommended |
|
to use one marshal per Python library (e.g. package on PyPI). |
|
manifest (Set[str]): A set of messages and enums to be created. Setting |
|
this adds a slight efficiency in piecing together proto |
|
descriptors under the hood. |
|
""" |
|
if not marshal: |
|
marshal = package |
|
return _ProtoModule( |
|
package=package, |
|
marshal=marshal, |
|
manifest=frozenset(manifest), |
|
) |
|
|
|
|
|
__all__ = ("define_module",) |
|
|