verify_security_answers. Internal helper function. This docstring was added automatically to improve maintainability. Args: username: Parameter. answers: Parameter. Returns: Varies.
(username: str, answers: dict)
| 11096 | |
| 11097 | return feeds |
| 11098 | |
| 11099 | def _norm_space(s: str) -> str: |
| 11100 | return re.sub(r"\s+", " ", (s or "")).strip() |
| 11101 | |
| 11102 | def _parse_rss_items(xml_bytes: bytes, source: str, topic_key: str, topic_label: str, is_google: bool) -> List[Dict[str, str]]: |
| 11103 | """Parse RSS/Atom bytes into a list of items: {title,url,source,topic_key,topic,published}.""" |
| 11104 | out: List[Dict[str, str]] = [] |
| 11105 | try: |
| 11106 | import xml.etree.ElementTree as ET |
| 11107 | root = ET.fromstring(xml_bytes) |
| 11108 | except Exception: |
| 11109 | return out |
| 11110 | |
| 11111 | def txt(el): |
| 11112 | if el is None: |
| 11113 | return "" |
| 11114 | return _norm_space("".join(el.itertext())) |
| 11115 | |
| 11116 | def norm_title(t: str) -> Tuple[str, str]: |
| 11117 | """For Google News RSS, try to split 'Title - Publisher'.""" |
| 11118 | if not is_google: |
| 11119 | return t, source |
| 11120 | t = (t or "").strip() |
| 11121 | if " - " in t: |
| 11122 | a, b = t.rsplit(" - ", 1) |
| 11123 | if a.strip() and b.strip(): |
| 11124 | return a.strip(), b.strip() |
| 11125 | return t, source |
no test coverage detected