Explorer
/proc/28/root/tmp/patch_aa022_dates_obs.py
← Zurück ↓ Download
from pathlib import Path
p=Path('/opt/struktur/social-media-radar/intake/rss_intake.py')
s=p.read_text()
s=s.replace('''        record_source_run(feed["name"], t0, stats["seen"], stats["new"],
                          stats["duplicates"], rejected=stats["rejected"],
                          quota_usage=f"parsed={stats['parsed']};canonicalized={stats['parsed']}")
''','''        record_source_run(feed["name"], t0, stats["seen"], stats["new"],
                          stats["duplicates"], rejected=stats["rejected"],
                          quota_usage="", items_parsed=stats["parsed"],
                          items_canonicalized=stats["parsed"])
''',1)
p.write_text(s)

p=Path('/opt/struktur/social-media-radar/intake/watch_intake.py')
s=p.read_text()
for old,new in [
("item.find('title') or item.find('./{http://www.w3.org/2005/Atom}title')", "item.find('title') if item.find('title') is not None else item.find('./{http://www.w3.org/2005/Atom}title')"),
("item.find('link') or item.find('./{http://www.w3.org/2005/Atom}link')", "item.find('link') if item.find('link') is not None else item.find('./{http://www.w3.org/2005/Atom}link')"),
("item.find('pubDate') or item.find('./{http://www.w3.org/2005/Atom}published') or item.find('./{http://purl.org/rss/1.0/modules/dc/}date')", "item.find('pubDate') if item.find('pubDate') is not None else (item.find('./{http://www.w3.org/2005/Atom}published') if item.find('./{http://www.w3.org/2005/Atom}published') is not None else item.find('./{http://purl.org/rss/1.0/modules/dc/}date'))"),
("item.find('description') or item.find('./{http://www.w3.org/2005/Atom}summary')", "item.find('description') if item.find('description') is not None else item.find('./{http://www.w3.org/2005/Atom}summary')")]:
    s=s.replace(old,new)
p.write_text(s)