2 from _typeshed import SupportsWrite
3 from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar, Union
5 from .descriptor import FieldDescriptor
6 from .descriptor_pool import DescriptorPool
7 from .message import Message
9 if sys.version_info < (3, 0):
12 _M = TypeVar("_M", bound=Message) # message type (of self)
14 class Error(Exception): ...
16 class ParseError(Error):
17 def __init__(self, message: Optional[str] = ..., line: Optional[int] = ..., column: Optional[int] = ...) -> None: ...
18 def GetLine(self) -> Optional[int]: ...
19 def GetColumn(self) -> Optional[int]: ...
22 def __init__(self, as_utf8: bool) -> None: ...
23 def write(self, val: Text) -> int: ...
24 def getvalue(self) -> str: ...
25 def close(self) -> None: ...
27 _MessageFormatter = Callable[[Message, int, bool], Optional[Text]]
32 as_one_line: bool = ...,
33 use_short_repeated_primitives: bool = ...,
34 pointy_brackets: bool = ...,
35 use_index_order: bool = ...,
36 float_format: Optional[str] = ...,
37 double_format: Optional[str] = ...,
38 use_field_number: bool = ...,
39 descriptor_pool: Optional[DescriptorPool] = ...,
41 message_formatter: Optional[_MessageFormatter] = ...,
42 print_unknown_fields: bool = ...,
43 force_colon: bool = ...,
48 as_one_line: bool = ...,
49 use_short_repeated_primitives: bool = ...,
50 pointy_brackets: bool = ...,
51 use_index_order: bool = ...,
52 float_format: Optional[str] = ...,
53 double_format: Optional[str] = ...,
54 use_field_number: bool = ...,
55 descriptor_pool: Optional[DescriptorPool] = ...,
57 message_formatter: _MessageFormatter = ...,
58 print_unknown_fields: bool = ...,
59 force_colon: bool = ...,
63 out: SupportsWrite[str],
66 as_one_line: bool = ...,
67 use_short_repeated_primitives: bool = ...,
68 pointy_brackets: bool = ...,
69 use_index_order: bool = ...,
70 float_format: Optional[str] = ...,
71 double_format: Optional[str] = ...,
72 use_field_number: bool = ...,
73 descriptor_pool: Optional[DescriptorPool] = ...,
74 message_formatter: Optional[_MessageFormatter] = ...,
75 print_unknown_fields: bool = ...,
76 force_colon: bool = ...,
79 field: FieldDescriptor,
81 out: SupportsWrite[str],
84 as_one_line: bool = ...,
85 use_short_repeated_primitives: bool = ...,
86 pointy_brackets: bool = ...,
87 use_index_order: bool = ...,
88 float_format: Optional[str] = ...,
89 double_format: Optional[str] = ...,
90 message_formatter: Optional[_MessageFormatter] = ...,
91 print_unknown_fields: bool = ...,
92 force_colon: bool = ...,
95 field: FieldDescriptor,
97 out: SupportsWrite[str],
100 as_one_line: bool = ...,
101 use_short_repeated_primitives: bool = ...,
102 pointy_brackets: bool = ...,
103 use_index_order: bool = ...,
104 float_format: Optional[str] = ...,
105 double_format: Optional[str] = ...,
106 message_formatter: Optional[_MessageFormatter] = ...,
107 print_unknown_fields: bool = ...,
108 force_colon: bool = ...,
112 out: SupportsWrite[str] = ...
115 as_one_line: bool = ...
116 use_short_repeated_primitives: bool = ...
117 pointy_brackets: bool = ...
118 use_index_order: bool = ...
119 float_format: Optional[str] = ...
120 double_format: Optional[str] = ...
121 use_field_number: bool = ...
122 descriptor_pool: Optional[DescriptorPool] = ...
123 message_formatter: Optional[_MessageFormatter] = ...
124 print_unknown_fields: bool = ...
125 force_colon: bool = ...
128 out: SupportsWrite[str],
131 as_one_line: bool = ...,
132 use_short_repeated_primitives: bool = ...,
133 pointy_brackets: bool = ...,
134 use_index_order: bool = ...,
135 float_format: Optional[str] = ...,
136 double_format: Optional[str] = ...,
137 use_field_number: bool = ...,
138 descriptor_pool: Optional[DescriptorPool] = ...,
139 message_formatter: Optional[_MessageFormatter] = ...,
140 print_unknown_fields: bool = ...,
141 force_colon: bool = ...,
143 def PrintMessage(self, message: Message) -> None: ...
144 def PrintField(self, field: FieldDescriptor, value: Any) -> None: ...
145 def PrintFieldValue(self, field: FieldDescriptor, value: Any) -> None: ...
148 text: Union[Text, bytes],
150 allow_unknown_extension: bool = ...,
151 allow_field_number: bool = ...,
152 descriptor_pool: Optional[DescriptorPool] = ...,
153 allow_unknown_field: bool = ...,
156 text: Union[Text, bytes],
158 allow_unknown_extension: bool = ...,
159 allow_field_number: bool = ...,
160 descriptor_pool: Optional[DescriptorPool] = ...,
161 allow_unknown_field: bool = ...,
164 lines: Iterable[Union[Text, bytes]],
166 allow_unknown_extension: bool = ...,
167 allow_field_number: bool = ...,
168 descriptor_pool: Optional[DescriptorPool] = ...,
169 allow_unknown_field: bool = ...,
173 allow_unknown_extension: bool = ...
174 allow_field_number: bool = ...
175 descriptor_pool: Optional[DescriptorPool] = ...
176 allow_unknown_field: bool = ...
179 allow_unknown_extension: bool = ...,
180 allow_field_number: bool = ...,
181 descriptor_pool: Optional[DescriptorPool] = ...,
182 allow_unknown_field: bool = ...,
184 def ParseLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ...
185 def MergeLines(self, lines: Iterable[Union[Text, bytes]], message: _M) -> _M: ...
187 _ParseError = ParseError
191 def __init__(self, lines: Iterable[str], skip_comments: bool = ...) -> None: ...
192 def LookingAt(self, token: str) -> bool: ...
193 def AtEnd(self) -> bool: ...
194 def TryConsume(self, token: str) -> bool: ...
195 def Consume(self, token: str) -> None: ...
196 def ConsumeComment(self) -> str: ...
197 def ConsumeCommentOrTrailingComment(self) -> Tuple[bool, str]: ...
198 def TryConsumeIdentifier(self) -> bool: ...
199 def ConsumeIdentifier(self) -> str: ...
200 def TryConsumeIdentifierOrNumber(self) -> bool: ...
201 def ConsumeIdentifierOrNumber(self) -> str: ...
202 def TryConsumeInteger(self) -> bool: ...
203 def ConsumeInteger(self) -> int: ...
204 def TryConsumeFloat(self) -> bool: ...
205 def ConsumeFloat(self) -> float: ...
206 def ConsumeBool(self) -> bool: ...
207 def TryConsumeByteString(self) -> bool: ...
208 def ConsumeString(self) -> Text: ...
209 def ConsumeByteString(self) -> bytes: ...
210 def ConsumeEnum(self, field: FieldDescriptor) -> int: ...
211 def ParseErrorPreviousToken(self, message: Message) -> _ParseError: ...
212 def ParseError(self, message: Message) -> _ParseError: ...
213 def NextToken(self) -> None: ...
215 def ParseInteger(text: str, is_signed: bool = ..., is_long: bool = ...) -> int: ...
216 def ParseFloat(text: str) -> float: ...
217 def ParseBool(text: str) -> bool: ...
218 def ParseEnum(field: FieldDescriptor, value: str) -> int: ...