import re,json,subprocess,argparse from pathlib import Path from html.parser import HTMLParser r=Path('/Users/gavrilovdev/tmp/progcode.ru');w=r/'web';base=Path('/tmp/progcode-metrika-frozen-527ea7bf774e');parser=argparse.ArgumentParser();parser.add_argument('--candidate',type=Path,default=Path('/tmp/progcode-ds-frozen-f5d927948163'));args=parser.parse_args();new=args.candidate;source=json.loads((new/'build-identity.json').read_text())['sourceHash'];out=r/'docs/design-system/candidates'/source[:12];out.mkdir(parents=True,exist_ok=True) for name in ['articles-v2.json','articles.json','publication-report.json','archive-routes.json','shortlinks.json','figure-placements.json']: assert subprocess.run(['git','show','0458a99:web/data/'+name],cwd=r,capture_output=True,check=True).stdout==(w/'data'/name).read_bytes(),name oldpages={p.relative_to(base) for p in base.rglob('*.html')};newpages={p.relative_to(new) for p in new.rglob('*.html')};assert oldpages<=newpages class Times(HTMLParser): def __init__(self,text):super().__init__();self.current=None;self.values=[];self.feed(text) def handle_starttag(self,tag,attrs): if tag=='time':self.current=[dict(attrs).get('datetime'),''] def handle_data(self,text): if self.current is not None:self.current[1]+=text def handle_endtag(self,tag): if tag=='time' and self.current is not None:self.values.append(tuple(self.current));self.current=None def inner(html): m=re.search(r']*class="[^"]*\barticle-content\b[^"]*"[^>]*>',html);assert m start=m.end();depth=1 for tag in re.finditer(r']*>',html[start:]): depth+=-1 if tag.group().startswith('