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

Function _parse_overview

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

Parse the response to an OVER or XOVER command according to the overview format `fmt`.

(lines, fmt, data_process_func=None)

Source from the content-addressed store, hash-verified

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
208 overview format `fmt`."""
209 n_defaults = len(_DEFAULT_OVERVIEW_FMT)
210 overview = []
211 for line in lines:
212 fields = {}
213 article_number, *tokens = line.split('\t')
214 article_number = int(article_number)
215 for i, token in enumerate(tokens):
216 if i >= len(fmt):
217 # XXX should we raise an error? Some servers might not
218 # support LIST OVERVIEW.FMT and still return additional
219 # headers.
220 continue
221 field_name = fmt[i]
222 is_metadata = field_name.startswith(':')
223 if i >= n_defaults and not is_metadata:
224 # Non-default header names are included in full in the response
225 # (unless the field is totally empty)
226 h = field_name + ": "
227 if token and token[:len(h)].lower() != h:
228 raise NNTPDataError("OVER/XOVER response doesn't include "
229 "names of additional headers")
230 token = token[len(h):] if token else None
231 fields[fmt[i]] = token
232 overview.append((article_number, fields))
233 return overview
234
235def _parse_datetime(date_str, time_str=None):
236 """Parse a pair of (date, time) strings, and return a datetime object.

Callers 2

xoverMethod · 0.85
overMethod · 0.85

Calls 6

enumerateFunction · 0.85
NNTPDataErrorClass · 0.85
startswithMethod · 0.80
splitMethod · 0.45
lowerMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected