Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/proto/modules.py: 89%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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.
15import collections
16from typing import Set
18_ProtoModule = collections.namedtuple(
19 "ProtoModule",
20 ["package", "marshal", "manifest"],
21)
24def define_module(
25 *, package: str, marshal: str = None, manifest: Set[str] = frozenset()
26) -> _ProtoModule:
27 """Define a protocol buffers module.
29 The settings defined here are used for all protobuf messages
30 declared in the module of the given name.
32 Args:
33 package (str): The proto package name.
34 marshal (str): The name of the marshal to use. It is recommended
35 to use one marshal per Python library (e.g. package on PyPI).
36 manifest (Set[str]): A set of messages and enums to be created. Setting
37 this adds a slight efficiency in piecing together proto
38 descriptors under the hood.
39 """
40 if not marshal:
41 marshal = package
42 return _ProtoModule(
43 package=package,
44 marshal=marshal,
45 manifest=frozenset(manifest),
46 )
49__all__ = ("define_module",)