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)
| 179 | return ''.join(parts) |
| 180 | |
| 181 | def _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 | |
| 206 | def _parse_overview(lines, fmt, data_process_func=None): |
| 207 | """Parse the response to an OVER or XOVER command according to the |
no test coverage detected