14 lines
2.7 KiB
Python
14 lines
2.7 KiB
Python
from pathlib import Path
|
|
from urllib.parse import unquote,urlsplit
|
|
import runpy,json,collections,xml.etree.ElementTree as ET
|
|
r=Path(__file__).resolve().parents[4];n=runpy.run_path(str(r/'deploy/audit-outbound.py'));scan=n['scan'];records=n['records'];base=r/'docs/rebuild-v2/semrush/first100';routes=json.loads((r/'web/data/archive-routes.json').read_text());fetches=json.loads((base/'fresh-comment-fetch.json').read_text())+json.loads((base/'fetch-evidence.json').read_text());extra=0
|
|
for v in fetches:
|
|
p=r/v['rawFile'];origin=v.get('originalCDXRow',{}).get('original');slug=routes.get(unquote(urlsplit(origin).path).rstrip('/'),{}).get('slug') if origin else None
|
|
if p.name in ['feed.capture','comments-feed.capture']:
|
|
x=ET.fromstring(p.read_bytes())
|
|
for i,item in enumerate(x.findall('./channel/item')):
|
|
link=item.findtext('link');slug=routes[unquote(urlsplit(link).path).rstrip('/')]['slug'];content=item.findtext('{http://purl.org/rss/1.0/modules/content/}encoded') or item.findtext('description') or '';scan('<div class="entry-content">'+content+'</div>',str(p.relative_to(r))+'#item'+str(i),'raw',slug)
|
|
else:scan(p.read_text(),str(p.relative_to(r)),'raw',slug)
|
|
extra+=1
|
|
result={'schemaVersion':2,'decisionMethod':'Perarticle/anchor/purpose, no domainwhitelist. Rawcomments notrepublished; independentlyverified usefulDietconsequence editoriallyparaphrased inoneboundedparagraph.','scope':{'sourceHash':json.loads((r/'web/public/build-identity.json').read_text())['sourceHash'],'staticGeneratedHTML':81,'currentDOM':'Only4actualDietcanonical/legacy390/1440cases, not full14/44browseraudit','freshArchiveCapturesAdded':extra,'historicalFullDOMRecord':'Previous656fullDOM scope preservedinGit history; not assertedfornewsource'},'counts':dict(collections.Counter(v['phase'] for v in records)),'unreviewed':sum(not v['editorialReviewed'] for v in records),'occurrences':records};(r/'docs/rebuild-v2/outbound-links.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n');assert result['unreviewed']==0,[v for v in records if not v['editorialReviewed']];url='https://vibed.org/templates/diet';new=[v for v in records if v['destination']==url];assert len([v for v in new if v['phase']=='edited-body'])==1 and len([v for v in new if v['phase']=='build'])==2 and len([v for v in new if v['phase']=='dom'])==4;assert all(v['editorialReviewed'] for v in new);(Path(__file__).parent/'new-link-audit.json').write_text(json.dumps({'url':url,'HTTPProof':'primary-source-check.json','occurrences':new,'allPurposeReviewed':True,'globalLedgerRows':len(records),'globalUnreviewed':0,'scope':result['scope']},ensure_ascii=False,indent=2)+'\n');print({'ledgerRows':len(records),'unreviewed':0,'newURLRows':len(new),'counts':result['counts']})
|