Parse the response to an OVER or XOVER command according to the overview format `fmt`.
(lines, fmt, data_process_func=None)
| 204 | return fmt |
| 205 | |
| 206 | def _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 | |
| 235 | def _parse_datetime(date_str, time_str=None): |
| 236 | """Parse a pair of (date, time) strings, and return a datetime object. |
no test coverage detected