settings_change_password. Internal helper function. This docstring was added automatically to improve maintainability. Returns: Varies.
()
| 11160 | link = "" |
| 11161 | if link_el is not None: |
| 11162 | link = link_el.get("href") or "" |
| 11163 | pub = txt(entry.find("a:updated", ns)) or txt(entry.find("a:published", ns)) |
| 11164 | push_item(title, link, pub) |
| 11165 | except Exception: |
| 11166 | pass |
| 11167 | |
| 11168 | return out |
| 11169 | |
| 11170 | def _fetch_url(url: str, timeout: int = 7) -> bytes: |
| 11171 | req = urllib.request.Request( |
| 11172 | url, |
| 11173 | headers={ |
| 11174 | "User-Agent": "ButSystem/1.1 (+RSS)", |
| 11175 | "Accept": "application/xml,text/xml,application/rss+xml,application/atom+xml,*/*", |
| 11176 | }, |
| 11177 | ) |
| 11178 | with urllib.request.urlopen(req, timeout=timeout) as r: |
| 11179 | return r.read() |
| 11180 | |
| 11181 | def _fetch_news_uncached(lang: str) -> List[Dict[str, str]]: |
| 11182 | feeds = _news_feeds_for_lang(lang) |
| 11183 | items: List[Dict[str, str]] = [] |
| 11184 | |
| 11185 | def fetch_one(feed): |
| 11186 | source, url, tkey, tlabel, is_google = feed |
| 11187 | try: |
| 11188 | xmlb = _fetch_url(url, timeout=7) |
| 11189 | return _parse_rss_items(xmlb, source, tkey, tlabel, is_google) |
| 11190 | except Exception: |
| 11191 | return [] |
| 11192 | |
| 11193 | # More interests means many feeds. Fetch concurrently so News does not become dramatically slower. |
| 11194 | workers = min(12, max(4, len(feeds))) |
| 11195 | with ThreadPoolExecutor(max_workers=workers, thread_name_prefix="ButSystemNews") as pool: |
| 11196 | futures = [pool.submit(fetch_one, feed) for feed in feeds] |
| 11197 | for future in as_completed(futures): |
| 11198 | try: |
nothing calls this directly
no test coverage detected