Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/proto/modules.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15from typing import Set
16import collections
19_ProtoModule = collections.namedtuple(
20 "ProtoModule",
21 ["package", "marshal", "manifest"],
22)
25def define_module(
26 *, package: str, marshal: str = None, manifest: Set[str] = frozenset()
27) -> _ProtoModule:
28 """Define a protocol buffers module.
30 The settings defined here are used for all protobuf messages
31 declared in the module of the given name.
33 Args:
34 package (str): The proto package name.
35 marshal (str): The name of the marshal to use. It is recommended
36 to use one marshal per Python library (e.g. package on PyPI).
37 manifest (Set[str]): A set of messages and enums to be created. Setting
38 this adds a slight efficiency in piecing together proto
39 descriptors under the hood.
40 """
41 if not marshal:
42 marshal = package
43 return _ProtoModule(
44 package=package,
45 marshal=marshal,
46 manifest=frozenset(manifest),
47 )
50__all__ = ("define_module",)