MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _parse_overview_fmt

Function _parse_overview_fmt

tools/python-3.11.9-amd64/Lib/nntplib.py:181–204  ·  view source on GitHub ↗

Parse a list of string representing the response to LIST OVERVIEW.FMT and return a list of header/metadata names. Raises NNTPDataError if the response is not compliant (cf. RFC 3977, section 8.4).

(lines)

Source from the content-addressed store, hash-verified

179 return ''.join(parts)
180
181def _parse_overview_fmt(lines):
182 """Parse a list of string representing the response to LIST OVERVIEW.FMT
183 and return a list of header/metadata names.
184 Raises NNTPDataError if the response is not compliant
185 (cf. RFC 3977, section 8.4)."""
186 fmt = []
187 for line in lines:
188 if line[0] == ':':
189 # Metadata name (e.g. ":bytes")
190 name, _, suffix = line[1:].partition(':')
191 name = ':' + name
192 else:
193 # Header name (e.g. "Subject:" or "Xref:full")
194 name, _, suffix = line.partition(':')
195 name = name.lower()
196 name = _OVERVIEW_FMT_ALTERNATIVES.get(name, name)
197 # Should we do something with the suffix?
198 fmt.append(name)
199 defaults = _DEFAULT_OVERVIEW_FMT
200 if len(fmt) < len(defaults):
201 raise NNTPDataError("LIST OVERVIEW.FMT response too short")
202 if fmt[:len(defaults)] != defaults:
203 raise NNTPDataError("LIST OVERVIEW.FMT redefines default fields")
204 return fmt
205
206def _parse_overview(lines, fmt, data_process_func=None):
207 """Parse the response to an OVER or XOVER command according to the

Callers 1

_getoverviewfmtMethod · 0.85

Calls 5

NNTPDataErrorClass · 0.85
partitionMethod · 0.80
lowerMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected