Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c97ea94b49 | |||
| 59053fd4fb |
@@ -49,6 +49,21 @@ jobs:
|
|||||||
subprocess.run([str(venv/'bin/paper-atlas'),'--help'],cwd=outside,check=True)
|
subprocess.run([str(venv/'bin/paper-atlas'),'--help'],cwd=outside,check=True)
|
||||||
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','cvf','--help'],cwd=outside,check=True)
|
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','cvf','--help'],cwd=outside,check=True)
|
||||||
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','rss2026-proceedings','--help'],cwd=outside,check=True)
|
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','rss2026-proceedings','--help'],cwd=outside,check=True)
|
||||||
|
eccv_fixture = json.loads(gzip.decompress((src/'tests/fixtures/eccv2026-source.json.gz').read_bytes()))
|
||||||
|
eccv_official = root/'eccv2026-official'
|
||||||
|
eccv_papers = root/'eccv2026-paper-samples'
|
||||||
|
eccv_official.mkdir(); eccv_papers.mkdir()
|
||||||
|
for name, html in eccv_fixture['official_pages'].items():
|
||||||
|
(eccv_official/name).write_text(html)
|
||||||
|
(eccv_official/'manifest.json').write_text(eccv_fixture['official_manifest'])
|
||||||
|
for pid, html in eccv_fixture['paper_pages'].items():
|
||||||
|
(eccv_papers/(pid+'.html')).write_text(html)
|
||||||
|
(eccv_papers/'manifest.json').write_text(json.dumps(eccv_fixture['paper_manifest']))
|
||||||
|
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','eccv2026-program','--official-snapshots',str(eccv_official),'--paper-snapshots',str(eccv_papers),'--out',str(root/'installed-eccv2026')],cwd=outside,check=True)
|
||||||
|
eccv_report = json.loads((root/'installed-eccv2026/collection-report.json').read_text())
|
||||||
|
assert eccv_report['records'] == 3 and eccv_report['expected_program_ids'] == 2834
|
||||||
|
assert eccv_report['duplicate_program_occurrences'] == 17 and len(eccv_report['uncollected_program_ids']) == 2831
|
||||||
|
assert not eccv_report['database_written'] and eccv_report['files'][0]['track'] == 'program_unclassified'
|
||||||
icaps_fixture = json.loads(gzip.decompress((src/'tests/fixtures/icaps2026-source.json.gz').read_bytes()))
|
icaps_fixture = json.loads(gzip.decompress((src/'tests/fixtures/icaps2026-source.json.gz').read_bytes()))
|
||||||
icaps_snapshots = root/'icaps2026-snapshots'
|
icaps_snapshots = root/'icaps2026-snapshots'
|
||||||
icaps_snapshots.mkdir()
|
icaps_snapshots.mkdir()
|
||||||
|
|||||||
@@ -128,3 +128,5 @@ ICAPS 2026 也提供独立的 `collect icaps2026-registry`,保留 Crossref 卷
|
|||||||
### CoRL 2026 官方程序快照
|
### CoRL 2026 官方程序快照
|
||||||
|
|
||||||
`collect corl2026-program` 将官方 687 个论坛与固定公开档案按 ID 对照,保留 34 条标题版本差异及分字段来源。不会自动接受 arXiv 匹配或推断拒稿;详情见 [CoRL 2026 使用与恢复说明](docs/corl2026-program.md)。
|
`collect corl2026-program` 将官方 687 个论坛与固定公开档案按 ID 对照,保留 34 条标题版本差异及分字段来源。不会自动接受 arXiv 匹配或推断拒稿;详情见 [CoRL 2026 使用与恢复说明](docs/corl2026-program.md)。
|
||||||
|
|
||||||
|
ECCV 2026 的[暂定节目采集器](docs/eccv2026-program.md)合并重复节目 ID,并以不可变缓存断点采集公开元数据;保留摘要原文、来源关键词及未分类 track,始终待身份审核,不自动入库。
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# ECCV 2026:暂定节目与公开元数据
|
||||||
|
|
||||||
|
这是长期维护、按需运行的来源适配器。它读取已核验的官方节目快照,采集公开论文页的标题、完整作者和摘要,输出待身份审核文件;不连接数据库,不下载 PDF、评审、个人档案或受保护的直播内容。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
paper-atlas collect eccv2026-program \
|
||||||
|
--official-snapshots /data/paper-index/collected/eccv2026-official-research-v1 \
|
||||||
|
--cache /data/paper-index/cache/eccv2026-public-pages \
|
||||||
|
--max-new-pages 200 \
|
||||||
|
--out /data/paper-index/collected/eccv2026-pass01
|
||||||
|
```
|
||||||
|
|
||||||
|
官方目录包含 `accepted.html`、`policies.html`、`faq.html` 和冻结的 `manifest.json`。当前适配器核验固定版本:节目 2,851 行、2,834 个节目 ID;17 个 ID 各重复一次,标题、作者、关键词、展示信息均一致。输出按节目 ID 合并这些重复行,并保留全部行序号。它不是跨来源作品去重。
|
||||||
|
|
||||||
|
`--max-new-pages` 限制本轮新请求数;不指定时遍历整个冻结名单。再次运行时使用同一 `--cache` 和**全新** `--out`,复用已验证缓存并继续读取缺失页。缓存不按 24 小时过期,不自动刷新或覆盖已成功的原始响应。每次运行输出包含本轮能核验的全部缓存条目,并明确列出尚未采集的 ID;不能未经审核把多轮重叠输出全部重复导入。
|
||||||
|
|
||||||
|
公开请求按固定来源和路径限制,只接受 HTTP 200、原 URL、HTML 和限定大小的完整响应。请求失败、重定向、访问挑战、非 HTML 或异常响应留下阻断标记,不自动重试或更换账号、域名、代理绕过限制。记录的 `Retry-After` 供人工核查使用。网络超时等未产生成功缓存的情况可在确认进程终止后用新输出目录继续。缓存数据与回执须成对且哈希一致;遇到孤立文件或 `.part` 时保留现场,先核查再把本任务的残留文件移至恢复目录,不静默丢弃。写同一缓存时持有非阻塞单写锁。
|
||||||
|
|
||||||
|
离线重放可改用 `--paper-snapshots /path/to/papers`,该目录包含 `<节目ID>.html` 和 `manifest.json`(带时区的 `at`、`records`,各条含文件、URL、最终 URL、HTTP 状态、类型、字节数、SHA-256)。缺少的公开页会明确列为未采集;三篇样本只会生成三条 partial 记录,不会冒充全量成功。
|
||||||
|
|
||||||
|
## 来源边界
|
||||||
|
|
||||||
|
[官方名单](https://eccv.ecva.net/Conferences/2026/AcceptedPapers)明确注明 **preliminary pending publisher checks**。这里的 accepted 表示冻结时列入暂定官方名单,不代表已核验 Springer 最终发表或原始签名决定。所有输出始终 partial。节目 ID 是官方节目定位符,不冒充原始 OpenReview 投稿号;尚未核实跨平台标识时作品标识和投稿标识均为空。
|
||||||
|
|
||||||
|
公开页的 canonical URL、可见标题/作者和 JSON-LD 相互核对;页面版本与冻结节目文字有差异时分别保留并标记待审阅,不制造人名别名。JSON-LD 日期只是网站条目时间,不当作论文发表日期或原始决定日期。摘要保留公开页 DOM 文本(规范空白),包括源头的断词、缺空格;不自动修补。原始 HTML 单独留存;遇到公式、上下标或图片结构会标记待审阅,不能把扁平化文本当作无损数学表达。页面上的登录提示对应直播内容,不用于访问受保护内容。
|
||||||
|
|
||||||
|
官方关键词保存在独立 `eccv_program:keyword` 命名空间,并保留原始单元格和证据。关键词、展示形式、贡献/研究类型、自定义标签相互独立,投稿 track 暂用 `program_unclassified`,不按主题推断 main、findings、workshop 或 position。
|
||||||
|
|
||||||
|
[2026 投稿政策](https://eccv.ecva.net/Conferences/2026/SubmissionPolicies)明确评审和作者回复不公开;这不能代替对公开 rejected、desk rejected、withdrawn **决定元数据**的单独核查。当前拒稿决定可见性仍记为 unknown,不能从录用表缺席推断拒稿。
|
||||||
|
|
||||||
|
失败输出保留 `failed.json`,成功报告最后发布;恢复前核查既有进程、输出及缓存,不因日志安静重启。身份、来源版本和完整投稿历史审阅后,另行准备专用入库队列、保护基线和导入后验收;全部来源导入结束后仍须全库去重、覆盖、摘要、约束及查询审计。测试、构建及安装验证只在已授权 `ces-control:host` runner 执行。
|
||||||
@@ -24,6 +24,7 @@ COMMANDS = {
|
|||||||
('collect','neurips'): ('paper_atlas.collectors.proceedings', {'source':'neurips'}, 'NeurIPS 官方论文集'),
|
('collect','neurips'): ('paper_atlas.collectors.proceedings', {'source':'neurips'}, 'NeurIPS 官方论文集'),
|
||||||
('collect','mlsys'): ('paper_atlas.collectors.proceedings', {'source':'mlsys'}, 'MLSys 官方历年标题与摘要'),
|
('collect','mlsys'): ('paper_atlas.collectors.proceedings', {'source':'mlsys'}, 'MLSys 官方历年标题与摘要'),
|
||||||
('collect','icaps2026-registry'): ('paper_atlas.collectors.icaps_registry2026', {}, '核验 ICAPS 2026 Crossref 注册元数据并保留独立版本'),
|
('collect','icaps2026-registry'): ('paper_atlas.collectors.icaps_registry2026', {}, '核验 ICAPS 2026 Crossref 注册元数据并保留独立版本'),
|
||||||
|
('collect','eccv2026-program'): ('paper_atlas.collectors.eccv2026', {}, '核验ECCV2026暂定节目并断点采集公开元数据'),
|
||||||
('collect','icaps2026-program'): ('paper_atlas.collectors.icaps2026', {}, '核验 ICAPS 2026 官方录用名单并分开既有论文展示'),
|
('collect','icaps2026-program'): ('paper_atlas.collectors.icaps2026', {}, '核验 ICAPS 2026 官方录用名单并分开既有论文展示'),
|
||||||
('collect','rss2026-proceedings'): ('paper_atlas.collectors.rss2026', {}, '核验 RSS 2026 官方论文集与独立录用表'),
|
('collect','rss2026-proceedings'): ('paper_atlas.collectors.rss2026', {}, '核验 RSS 2026 官方论文集与独立录用表'),
|
||||||
('collect','cvf'): ('paper_atlas.collectors.vision', {'source':'cvf'}, 'CVPR / ICCV 官方开放目录'),
|
('collect','cvf'): ('paper_atlas.collectors.vision', {'source':'cvf'}, 'CVPR / ICCV 官方开放目录'),
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
"""ECCV 2026 frozen preliminary program and resumable public metadata pages."""
|
||||||
|
import argparse
|
||||||
|
from collections import Counter
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import fcntl
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
|
||||||
|
from paper_atlas.io.html import Document, Node, clean
|
||||||
|
from paper_atlas.io.html_cache import PublicHTMLCache, checked_html, digest
|
||||||
|
|
||||||
|
SOURCE = 'eccv_program'
|
||||||
|
ORIGIN = 'https://eccv.ecva.net'
|
||||||
|
ACCEPTED = ORIGIN+'/Conferences/2026/AcceptedPapers'
|
||||||
|
TRACK = 'program_unclassified'
|
||||||
|
MANIFEST_SHA = '04f9734783bbbfa2e19f936d8f5a7aecfb524b0ceef33fc5d9fb6276c7b6678a'
|
||||||
|
PAGES = {'accepted.html': ACCEPTED, 'policies.html': ORIGIN+'/Conferences/2026/SubmissionPolicies',
|
||||||
|
'faq.html': ORIGIN+'/Conferences/2026/FAQs'}
|
||||||
|
|
||||||
|
|
||||||
|
def one(items):
|
||||||
|
if len(items) != 1:
|
||||||
|
raise ValueError('Expected one reviewed metadata field')
|
||||||
|
return items[0]
|
||||||
|
|
||||||
|
|
||||||
|
def has_class(node, value):
|
||||||
|
return value in node.attrs.get('class', '').split()
|
||||||
|
|
||||||
|
|
||||||
|
def parse_program(raw):
|
||||||
|
nodes = list(Document(raw).root.walk())
|
||||||
|
if len([n for n in nodes if n.tag == 'h2' and clean(n.text()) == 'ECCV 2026 Accepted Papers:']) != 1:
|
||||||
|
raise ValueError('Unexpected ECCV program edition')
|
||||||
|
if 'This paper list is preliminary pending publisher checks.' not in clean(Document(raw).root.text()):
|
||||||
|
raise ValueError('Reviewed provisional-publication notice changed')
|
||||||
|
table = one([n for n in nodes if n.tag == 'table' and n.attrs.get('id') == 'event-list-2026-poster-nodates-filter-vslinks-table'])
|
||||||
|
papers = {}; occurrences = 0
|
||||||
|
for tr in (n for n in table.walk() if n.tag == 'tr'):
|
||||||
|
cells = [n for n in tr.children if isinstance(n, Node) and n.tag == 'td']
|
||||||
|
if not cells:
|
||||||
|
continue
|
||||||
|
if len(cells) != 3:
|
||||||
|
raise ValueError('Unexpected program columns')
|
||||||
|
links = [n for n in cells[0].walk() if n.tag == 'a' and re.fullmatch(r'/virtual/2026/poster/[1-9][0-9]*', n.attrs.get('href', ''))]
|
||||||
|
link = one(links); pid = link.attrs['href'].rsplit('/', 1)[1]
|
||||||
|
authors = clean(one([n for n in cells[0].walk() if n.tag == 'i']).text())
|
||||||
|
row = {'title': clean(link.text()), 'authors_literal': authors,
|
||||||
|
'keywords_literal': clean(cells[1].text()), 'presentation_literal': clean(cells[2].text())}
|
||||||
|
if not row['title'] or not authors:
|
||||||
|
raise ValueError('Incomplete public program fields')
|
||||||
|
occurrences += 1
|
||||||
|
if pid in papers:
|
||||||
|
if papers[pid]['listing'] != row:
|
||||||
|
raise ValueError('Conflicting entries share a program ID')
|
||||||
|
papers[pid]['row_ordinals'].append(occurrences)
|
||||||
|
else:
|
||||||
|
papers[pid] = {'url': ORIGIN+link.attrs['href'], 'listing': row, 'row_ordinals': [occurrences]}
|
||||||
|
if occurrences != 2851 or len(papers) != 2834 or Counter(len(v['row_ordinals']) for v in papers.values()) != {1: 2817, 2: 17}:
|
||||||
|
raise ValueError('Incomplete reviewed program census')
|
||||||
|
return papers
|
||||||
|
|
||||||
|
|
||||||
|
def parse_paper(raw, url, program):
|
||||||
|
nodes = list(Document(raw).root.walk())
|
||||||
|
title = clean(one([n for n in nodes if n.tag == 'h1' and has_class(n, 'event-title')]).text())
|
||||||
|
authors_literal = clean(one([n for n in nodes if n.tag == 'div' and has_class(n, 'event-organizers')]).text())
|
||||||
|
abstract_node = one([n for n in nodes if n.tag == 'div' and has_class(n, 'abstract-text-inner')])
|
||||||
|
abstract = clean(abstract_node.text())
|
||||||
|
markup = sorted({n.tag for n in abstract_node.walk() if n.tag in ('math','sup','sub','svg','img')})
|
||||||
|
canonical = one([n.attrs.get('href') for n in nodes if n.tag == 'link' and n.attrs.get('rel') == 'canonical'])
|
||||||
|
scripts = [n for n in nodes if n.tag == 'script' and n.attrs.get('type') == 'application/ld+json']
|
||||||
|
ld = one([json.loads(''.join(x for x in n.children if isinstance(x, str))) for n in scripts])
|
||||||
|
authors = ld.get('author')
|
||||||
|
if (canonical != url or ld.get('@type') != 'CreativeWork' or ld.get('creditText') != 'ECCV 2026'
|
||||||
|
or not title or ld.get('name') != title or not abstract
|
||||||
|
or not isinstance(authors, list) or not authors
|
||||||
|
or any(not isinstance(a, dict) or a.get('@type') != 'Person' or not isinstance(a.get('name'), str)
|
||||||
|
or not clean(a['name']) or '@' in a['name'] for a in authors)):
|
||||||
|
raise ValueError('Public visible/structured metadata identity or edition disagrees')
|
||||||
|
names = [a['name'] for a in authors]
|
||||||
|
if ' ⋅ '.join(names) != authors_literal:
|
||||||
|
raise ValueError('Complete visible and structured authors disagree')
|
||||||
|
flags = ['structured_abstract_markup_requires_review'] if markup else []
|
||||||
|
if title != program['listing']['title']:
|
||||||
|
flags.append('program_and_page_title_versions_differ_requires_review')
|
||||||
|
if authors_literal != program['listing']['authors_literal']:
|
||||||
|
flags.append('program_and_page_author_versions_differ_requires_review')
|
||||||
|
return {'title': title, 'authors': names, 'authors_literal': authors_literal, 'abstract': abstract,
|
||||||
|
'page_metadata_dates': {k: ld.get(k) for k in ('datePublished', 'dateModified')}, 'review_flags': flags, 'abstract_markup_tags': markup}
|
||||||
|
|
||||||
|
|
||||||
|
def official_snapshot(root):
|
||||||
|
root = Path(root); manifest = root/'manifest.json'
|
||||||
|
if root.is_symlink() or manifest.is_symlink() or digest(manifest.read_bytes()) != MANIFEST_SHA:
|
||||||
|
raise ValueError('Reviewed official snapshot manifest changed')
|
||||||
|
m = json.loads(manifest.read_bytes())
|
||||||
|
if datetime.fromisoformat(m['at'].replace('Z', '+00:00')).utcoffset() is None:
|
||||||
|
raise ValueError('Official snapshot requires a timezone')
|
||||||
|
if len(m['sources']) != 3 or {r['file'] for r in m['sources']} != set(PAGES):
|
||||||
|
raise ValueError('Official source set changed')
|
||||||
|
pages = {}; evidence = {}
|
||||||
|
for r in m['sources']:
|
||||||
|
name = r['file']; p = root/name
|
||||||
|
if p.is_symlink() or p.stat().st_size > 8*1024**2:
|
||||||
|
raise ValueError('Unsafe official snapshot')
|
||||||
|
raw = p.read_bytes()
|
||||||
|
if r['url'] != PAGES[name] or r['final_url'] != r['url'] or r['http_status'] != 200 or r['bytes'] != len(raw) or r['sha256'] != digest(raw):
|
||||||
|
raise ValueError('Invalid official source receipt')
|
||||||
|
pages[name] = raw; evidence[name] = {'url': r['url'], 'sha256': digest(raw)}
|
||||||
|
program = parse_program(pages['accepted.html'].decode('utf-8'))
|
||||||
|
return m, pages, evidence, program
|
||||||
|
|
||||||
|
|
||||||
|
def paper_snapshots(root, program):
|
||||||
|
root = Path(root); path = root/'manifest.json'
|
||||||
|
if root.is_symlink() or path.is_symlink():
|
||||||
|
raise ValueError('Paper snapshot symlinks rejected')
|
||||||
|
if path.stat().st_size > 4*1024**2:
|
||||||
|
raise ValueError('Oversized paper manifest')
|
||||||
|
m = json.loads(path.read_bytes()); result = {}
|
||||||
|
for r in m['records']:
|
||||||
|
pid = r['paper_id']
|
||||||
|
if pid not in program or pid in result or r['file'] != pid+'.html':
|
||||||
|
raise ValueError('Foreign or repeated paper snapshot')
|
||||||
|
p = root/r['file']
|
||||||
|
if p.is_symlink() or p.stat().st_size > 2*1024**2:
|
||||||
|
raise ValueError('Unsafe paper snapshot')
|
||||||
|
receipt = {**r, 'retrieved_at': r.get('retrieved_at', m['at'])}
|
||||||
|
result[pid] = checked_html(p.read_bytes(), receipt, program[pid]['url'], 2*1024**2)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def collect(out, *, official_snapshots, paper_snapshots_dir=None, cache=None, max_new_pages=None):
|
||||||
|
if (paper_snapshots_dir is None) == (cache is None):
|
||||||
|
raise ValueError('Choose paper snapshots or public metadata cache')
|
||||||
|
if max_new_pages is not None and (type(max_new_pages) is not int or max_new_pages < 0 or cache is None):
|
||||||
|
raise ValueError('New-page budget requires cache mode and a nonnegative integer')
|
||||||
|
out = Path(out)
|
||||||
|
if out.exists():
|
||||||
|
raise ValueError('Output exists; inspect previous operation before retrying')
|
||||||
|
out.mkdir(parents=True)
|
||||||
|
lock = None
|
||||||
|
try:
|
||||||
|
official, pages, source_evidence, program = official_snapshot(official_snapshots)
|
||||||
|
directory = out/'evidence'; directory.mkdir()
|
||||||
|
for name, raw in pages.items():
|
||||||
|
rel = 'evidence/'+digest(raw)+'.html'; (out/rel).write_bytes(raw); source_evidence[name]['file'] = rel
|
||||||
|
snapshots = paper_snapshots(paper_snapshots_dir, program) if paper_snapshots_dir is not None else None
|
||||||
|
client = None
|
||||||
|
if cache is not None:
|
||||||
|
cache = Path(cache); cache.mkdir(parents=True, exist_ok=True)
|
||||||
|
if cache.is_symlink() or (cache/'.collector.lock').is_symlink():
|
||||||
|
raise ValueError('Cache lock symlinks rejected')
|
||||||
|
lock = (cache/'.collector.lock').open('a+')
|
||||||
|
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
client = PublicHTMLCache(cache, ORIGIN)
|
||||||
|
rows = []; missing = []; fetched = 0; reused = 0
|
||||||
|
for pid in sorted(program, key=int):
|
||||||
|
p = program[pid]
|
||||||
|
if snapshots is not None:
|
||||||
|
response = snapshots.get(pid)
|
||||||
|
else:
|
||||||
|
response = client.cached(p['url'])
|
||||||
|
if response is not None:
|
||||||
|
reused += 1
|
||||||
|
elif max_new_pages is None or fetched < max_new_pages:
|
||||||
|
response = client.get(p['url']); fetched += 1
|
||||||
|
if response is None:
|
||||||
|
missing.append(pid); continue
|
||||||
|
raw, receipt = response; fields = parse_paper(raw.decode('utf-8'), p['url'], p)
|
||||||
|
rel = 'evidence/'+digest(raw)+'.html'; (out/rel).write_bytes(raw)
|
||||||
|
keyword = p['listing']['keywords_literal']
|
||||||
|
rows.append({'source': SOURCE, 'external_id': '2026/'+pid, 'url': p['url'],
|
||||||
|
'title': fields['title'], 'authors': fields['authors'], 'abstract': fields['abstract'],
|
||||||
|
'identifiers': {}, 'submission_identifiers': [], 'venue': 'ECCV', 'year': 2026,
|
||||||
|
'track': TRACK, 'status': 'accepted', 'observed_at': official['at'],
|
||||||
|
'raw_decision': 'listed in frozen preliminary ECCV 2026 accepted program, pending publisher checks',
|
||||||
|
'evidence_url': ACCEPTED,
|
||||||
|
'tags': [{'namespace': SOURCE+':keyword', 'value': keyword}] if keyword else [],
|
||||||
|
'metadata': {'official_program': p, 'public_page_fields': fields,
|
||||||
|
'public_page_receipt': receipt, 'public_page_evidence': {'file': rel, 'sha256': digest(raw), 'url': p['url']},
|
||||||
|
'program_source_evidence': source_evidence, 'publication_state': 'preliminary_pending_publisher_checks',
|
||||||
|
'original_decision_signature_verified': False,
|
||||||
|
'program_id_semantics': 'Official program locator, not a verified original submission number or cross-platform identifier.',
|
||||||
|
'abstract_quality': 'Public display literal retained, including broken hyphenation/missing spaces; no automatic text repair.',
|
||||||
|
'date_semantics': 'JSON-LD dates describe the website entry, not verified paper publication or decision dates.',
|
||||||
|
'label_semantics': 'Official keyword namespace independent of track, contribution/research type and custom labels.',
|
||||||
|
'scope': 'Public metadata only; no protected live content, reviews, person profiles or PDFs. Requires work identity, metadata version and complete history review before import.'}})
|
||||||
|
if len(rows) % 10 == 0:
|
||||||
|
print(json.dumps({'phase': 'public_metadata', 'records': len(rows), 'new_pages': fetched,
|
||||||
|
'cached_pages': reused, 'expected_program_ids': 2834, 'at': datetime.now(timezone.utc).isoformat()}), flush=True)
|
||||||
|
files = []
|
||||||
|
if rows:
|
||||||
|
path = out/'eccv-program-2026-unclassified.jsonl'; payload = ''.join(json.dumps(r, ensure_ascii=False)+'\n' for r in rows).encode(); path.write_bytes(payload)
|
||||||
|
manifest = {'source': SOURCE, 'parser_version': 1, 'venue': 'ECCV', 'year': 2026, 'track': TRACK,
|
||||||
|
'count': len(rows), 'file': str(path), 'file_sha256': digest(payload), 'list_url': ACCEPTED,
|
||||||
|
'status': 'partial', 'missing_abstract_count': 0, 'source_expected_count': 2834}
|
||||||
|
path.with_suffix('.manifest.json').write_text(json.dumps(manifest, indent=2)+'\n'); files.append(manifest)
|
||||||
|
report = {'status': 'collected_pending_identity_review' if rows else 'no_public_metadata_collected',
|
||||||
|
'records': len(rows), 'files': files, 'expected_program_ids': 2834, 'program_occurrences': 2851,
|
||||||
|
'duplicate_program_occurrences': 17, 'uncollected_program_ids': missing,
|
||||||
|
'new_pages': fetched, 'reused_pages': reused, 'database_written': False,
|
||||||
|
'public_review_visibility': 'not_public_per_2026_policy', 'public_rejected_decision_metadata': 'unknown',
|
||||||
|
'scope': 'Always partial: preliminary program, unresolved track/identity/version coverage; not final whole-database deduplication.'}
|
||||||
|
part = out/'collection-report.json.part'; part.write_text(json.dumps(report, ensure_ascii=False, indent=2)+'\n'); part.replace(out/'collection-report.json')
|
||||||
|
return report
|
||||||
|
except Exception as error:
|
||||||
|
(out/'failed.json').write_text(json.dumps({'status': 'failed_not_complete', 'error_type': type(error).__name__,
|
||||||
|
'database_written': False, 'scope': 'Preserve this output and verified cache; resume with a new output directory after inspection.'})+'\n')
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
if lock is not None:
|
||||||
|
lock.close()
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv=None, *, prog=None):
|
||||||
|
parser = argparse.ArgumentParser(prog=prog, description=__doc__)
|
||||||
|
parser.add_argument('--official-snapshots', required=True)
|
||||||
|
group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
group.add_argument('--paper-snapshots')
|
||||||
|
group.add_argument('--cache')
|
||||||
|
parser.add_argument('--max-new-pages', type=int)
|
||||||
|
parser.add_argument('--out', required=True)
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
print(json.dumps(collect(args.out, official_snapshots=args.official_snapshots,
|
||||||
|
paper_snapshots_dir=args.paper_snapshots, cache=args.cache, max_new_pages=args.max_new_pages), ensure_ascii=False))
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
"""Immutable, receipt-checked public HTML cache; no expiry or silent refresh."""
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
|
|
||||||
|
def digest(raw):
|
||||||
|
return hashlib.sha256(raw).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def checked_html(raw, receipt, url, limit):
|
||||||
|
if (len(raw) > limit or receipt.get('url') != url or receipt.get('final_url') != url
|
||||||
|
or receipt.get('http_status') != 200 or receipt.get('bytes') != len(raw)
|
||||||
|
or receipt.get('sha256') != digest(raw)
|
||||||
|
or not str(receipt.get('content_type', '')).lower().startswith('text/html')
|
||||||
|
or datetime.fromisoformat(receipt['retrieved_at'].replace('Z', '+00:00')).utcoffset() is None):
|
||||||
|
raise ValueError('Invalid public HTML receipt, response or timestamp')
|
||||||
|
if any(v in raw.lower() for v in (b'<title>just a moment', b'cf-chl-', b'botstopper')):
|
||||||
|
raise ValueError('Access challenge; stop without bypass')
|
||||||
|
return raw, receipt
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, *args, **kwargs):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class PublicHTMLCache:
|
||||||
|
"""Caller holds a single-writer lock and restricts the allowed URL paths."""
|
||||||
|
def __init__(self, directory, origin, *, limit=2*1024**2, delay=1):
|
||||||
|
self.root = Path(directory)
|
||||||
|
self.root.mkdir(parents=True, exist_ok=True)
|
||||||
|
if self.root.is_symlink():
|
||||||
|
raise ValueError('Cache symlinks rejected')
|
||||||
|
self.origin = origin
|
||||||
|
self.limit = limit
|
||||||
|
self.delay = delay
|
||||||
|
self.opener = urllib.request.build_opener(NoRedirect())
|
||||||
|
|
||||||
|
def paths(self, url):
|
||||||
|
u = urlsplit(url)
|
||||||
|
if u.scheme != 'https' or u.username or u.password or u.fragment or u.scheme+'://'+u.netloc != self.origin:
|
||||||
|
raise ValueError('Unapproved public metadata origin')
|
||||||
|
key = digest(url.encode())
|
||||||
|
return self.root/(key+'.html'), self.root/(key+'.json'), self.root/(key+'.failed.json')
|
||||||
|
|
||||||
|
def cached(self, url):
|
||||||
|
body, receipt, failure = self.paths(url)
|
||||||
|
parts = (body.with_suffix('.html.part'), receipt.with_suffix('.json.part'))
|
||||||
|
if any(p.is_symlink() for p in (body, receipt, failure, *parts)):
|
||||||
|
raise ValueError('Cache symlinks rejected')
|
||||||
|
if any(p.exists() for p in parts):
|
||||||
|
raise ValueError('Incomplete cache part; preserve and inspect orphan before recovery')
|
||||||
|
if failure.exists():
|
||||||
|
raise ValueError('Previous access failure requires inspection; no automatic retry')
|
||||||
|
if body.exists() != receipt.exists():
|
||||||
|
raise ValueError('Incomplete cache pair; preserve and inspect orphan before recovery')
|
||||||
|
if not body.exists():
|
||||||
|
return None
|
||||||
|
if body.stat().st_size > self.limit or receipt.stat().st_size > 16*1024:
|
||||||
|
raise ValueError('Oversized cache entry')
|
||||||
|
return checked_html(body.read_bytes(), json.loads(receipt.read_bytes()), url, self.limit)
|
||||||
|
|
||||||
|
def get(self, url):
|
||||||
|
cached = self.cached(url)
|
||||||
|
if cached is not None:
|
||||||
|
return cached
|
||||||
|
body, receipt, failure = self.paths(url)
|
||||||
|
try:
|
||||||
|
request = urllib.request.Request(url, headers={'User-Agent': 'PaperAtlas/0.1 (public scholarly metadata research)'})
|
||||||
|
with self.opener.open(request, timeout=30) as response:
|
||||||
|
rec = {'url': url, 'final_url': response.geturl(), 'http_status': response.status,
|
||||||
|
'content_type': response.headers.get('Content-Type', '')}
|
||||||
|
if rec['final_url'] != url or rec['http_status'] != 200 or not rec['content_type'].lower().startswith('text/html'):
|
||||||
|
raise ValueError('Unexpected metadata redirect, HTTP status or content type')
|
||||||
|
raw = response.read(self.limit+1)
|
||||||
|
if len(raw) > self.limit:
|
||||||
|
raise ValueError('Metadata response exceeds size limit')
|
||||||
|
expected = response.headers.get('Content-Length')
|
||||||
|
if expected is not None and int(expected) != len(raw):
|
||||||
|
raise ConnectionError('Incomplete metadata response')
|
||||||
|
rec.update(bytes=len(raw), sha256=digest(raw), retrieved_at=datetime.now(timezone.utc).isoformat())
|
||||||
|
checked_html(raw, rec, url, self.limit)
|
||||||
|
except (urllib.error.HTTPError, ValueError) as error:
|
||||||
|
if isinstance(error, urllib.error.HTTPError):
|
||||||
|
status = error.code
|
||||||
|
retry_after = error.headers.get('Retry-After') if error.headers else None
|
||||||
|
error.close()
|
||||||
|
else:
|
||||||
|
status = None
|
||||||
|
retry_after = None
|
||||||
|
# Access errors remain sticky until the operator verifies availability.
|
||||||
|
failure.write_text(json.dumps({'url': url, 'http_status': status, 'retry_after': retry_after, 'error_type': type(error).__name__,
|
||||||
|
'scope': 'Inspect access/redirect/response failure before moving this marker aside; no bypass or automatic retry.'})+'\n')
|
||||||
|
raise
|
||||||
|
part = body.with_suffix('.html.part')
|
||||||
|
part.write_bytes(raw); part.replace(body)
|
||||||
|
part = receipt.with_suffix('.json.part')
|
||||||
|
part.write_text(json.dumps(rec, indent=2)+'\n'); part.replace(receipt)
|
||||||
|
time.sleep(self.delay)
|
||||||
|
return raw, rec
|
||||||
BIN
Binary file not shown.
@@ -0,0 +1,104 @@
|
|||||||
|
import copy
|
||||||
|
import gzip
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from paper_atlas.collectors import eccv2026 as c
|
||||||
|
from paper_atlas.io.html_cache import PublicHTMLCache
|
||||||
|
|
||||||
|
|
||||||
|
class ECCV2026Tests(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.bundle = json.loads(gzip.decompress((Path(__file__).parent/'fixtures/eccv2026-source.json.gz').read_bytes()))
|
||||||
|
cls.program = c.parse_program(cls.bundle['official_pages']['accepted.html'])
|
||||||
|
|
||||||
|
def snapshots(self, root):
|
||||||
|
official = root/'official'; paper = root/'paper'; official.mkdir(); paper.mkdir()
|
||||||
|
for name, raw in self.bundle['official_pages'].items():
|
||||||
|
(official/name).write_text(raw)
|
||||||
|
(official/'manifest.json').write_text(self.bundle['official_manifest'])
|
||||||
|
for pid, raw in self.bundle['paper_pages'].items():
|
||||||
|
(paper/(pid+'.html')).write_text(raw)
|
||||||
|
(paper/'manifest.json').write_text(json.dumps(self.bundle['paper_manifest']))
|
||||||
|
return official, paper
|
||||||
|
|
||||||
|
def test_complete_program_and_duplicate_occurrences_match_gold(self):
|
||||||
|
self.assertEqual(len(self.program), 2834)
|
||||||
|
self.assertEqual(sum(len(p['row_ordinals']) for p in self.program.values()), 2851)
|
||||||
|
for ordinal, gold in enumerate(self.bundle['inventory']['records'], 1):
|
||||||
|
item = self.program[gold['paper_id']]
|
||||||
|
self.assertEqual(item['listing'], {k: gold[k] for k in ('title','authors_literal','keywords_literal','presentation_literal')})
|
||||||
|
self.assertIn(ordinal, item['row_ordinals'])
|
||||||
|
|
||||||
|
def test_conflicting_duplicate_not_silently_folded(self):
|
||||||
|
title = 'Transferability Between Understanding and Generation in Unified Multimodal Models'
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Conflicting'):
|
||||||
|
c.parse_program(self.bundle['official_pages']['accepted.html'].replace('href="/virtual/2026/poster/3137">'+title, 'href="/virtual/2026/poster/3137">Conflicting title', 1))
|
||||||
|
|
||||||
|
def test_missing_member_and_changed_provisional_status_rejected(self):
|
||||||
|
html = self.bundle['official_pages']['accepted.html']
|
||||||
|
for changed in [html.replace('/virtual/2026/poster/4048', '/virtual/2024/poster/4048', 1),
|
||||||
|
html.replace('This paper list is preliminary pending publisher checks.', 'Final archival papers.')]:
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
c.parse_program(changed)
|
||||||
|
|
||||||
|
def test_public_page_fields_match_independent_sample_review(self):
|
||||||
|
for gold in self.bundle['paper_gold']['records']:
|
||||||
|
pid = gold['paper_id']; fields = c.parse_paper(self.bundle['paper_pages'][pid], gold['url'], self.program[pid])
|
||||||
|
self.assertEqual(fields['title'], gold['title']); self.assertEqual(fields['authors'], gold['authors'])
|
||||||
|
self.assertEqual(fields['abstract'], gold['abstract_literal']); self.assertFalse(fields['review_flags'])
|
||||||
|
self.assertIn('sig-nal', c.parse_paper(self.bundle['paper_pages']['4048'], self.program['4048']['url'], self.program['4048'])['abstract'])
|
||||||
|
|
||||||
|
def test_foreign_canonical_and_inconsistent_jsonld_author_rejected(self):
|
||||||
|
raw = self.bundle['paper_pages']['4048']; url = self.program['4048']['url']
|
||||||
|
for changed in [raw.replace(url, 'https://example.org/other'), raw.replace('Suhyeon Ha', 'Other Author', 1)]:
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
c.parse_paper(changed, url, self.program['4048'])
|
||||||
|
|
||||||
|
def test_program_and_page_versions_flagged_without_aliases(self):
|
||||||
|
program = copy.deepcopy(self.program['4048']); program['listing']['title'] = 'Earlier source title'
|
||||||
|
fields = c.parse_paper(self.bundle['paper_pages']['4048'], program['url'], program)
|
||||||
|
self.assertEqual(fields['review_flags'], ['program_and_page_title_versions_differ_requires_review'])
|
||||||
|
self.assertEqual(fields['title'], self.program['4048']['listing']['title'])
|
||||||
|
|
||||||
|
def test_partial_snapshot_collection_has_no_inferred_submission_ids(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root = Path(tmp); official, paper = self.snapshots(root)
|
||||||
|
report = c.collect(root/'out', official_snapshots=official, paper_snapshots_dir=paper)
|
||||||
|
self.assertEqual(report['records'], 3); self.assertEqual(len(report['uncollected_program_ids']), 2831)
|
||||||
|
self.assertEqual(report['public_rejected_decision_metadata'], 'unknown'); self.assertFalse(report['database_written'])
|
||||||
|
manifest, = report['files']; self.assertEqual(manifest['status'], 'partial'); self.assertEqual(manifest['source_expected_count'], 2834)
|
||||||
|
rows = [json.loads(l) for l in Path(manifest['file']).read_text().splitlines()]
|
||||||
|
self.assertEqual({r['external_id'] for r in rows}, {'2026/4048','2026/3137','2026/3652'})
|
||||||
|
self.assertTrue(all(not r['identifiers'] and not r['submission_identifiers'] and r['track']=='program_unclassified' for r in rows))
|
||||||
|
self.assertTrue(all(r['metadata']['publication_state']=='preliminary_pending_publisher_checks' and not r['metadata']['original_decision_signature_verified'] for r in rows))
|
||||||
|
self.assertTrue(all(t['namespace']=='eccv_program:keyword' for r in rows for t in r['tags']))
|
||||||
|
with self.assertRaisesRegex(ValueError, 'Output exists'):
|
||||||
|
c.collect(root/'out', official_snapshots=official, paper_snapshots_dir=paper)
|
||||||
|
|
||||||
|
def test_zero_network_budget_reuses_immutable_cache_only(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root = Path(tmp); official, _ = self.snapshots(root); client = PublicHTMLCache(root/'cache', c.ORIGIN)
|
||||||
|
for r in self.bundle['paper_manifest']['records']:
|
||||||
|
body, receipt, _ = client.paths(r['url']); body.write_text(self.bundle['paper_pages'][r['paper_id']]); receipt.write_text(json.dumps({**r,'retrieved_at':self.bundle['paper_manifest']['at']}))
|
||||||
|
with patch.object(PublicHTMLCache, 'get', side_effect=AssertionError('network forbidden')):
|
||||||
|
report = c.collect(root/'out', official_snapshots=official, cache=root/'cache', max_new_pages=0)
|
||||||
|
self.assertEqual((report['records'],report['new_pages'],report['reused_pages']), (3,0,3))
|
||||||
|
|
||||||
|
def test_tampered_snapshot_preserves_failure_without_success(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
root = Path(tmp); official, paper = self.snapshots(root); (paper/'4048.html').write_text('tampered')
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
c.collect(root/'out', official_snapshots=official, paper_snapshots_dir=paper)
|
||||||
|
self.assertTrue((root/'out/failed.json').exists()); self.assertFalse((root/'out/collection-report.json').exists())
|
||||||
|
|
||||||
|
def test_structured_math_markup_requires_explicit_review(self):
|
||||||
|
raw = self.bundle['paper_pages']['4048']
|
||||||
|
self.assertIn('<p>Proactive tamper', raw)
|
||||||
|
fields = c.parse_paper(raw.replace('<p>Proactive tamper', '<p>10<sup>6</sup> Proactive tamper', 1), self.program['4048']['url'], self.program['4048'])
|
||||||
|
self.assertIn('structured_abstract_markup_requires_review', fields['review_flags'])
|
||||||
|
self.assertEqual(fields['abstract_markup_tags'], ['sup'])
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
from datetime import datetime, timezone
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
import urllib.error
|
||||||
|
|
||||||
|
from paper_atlas.io.html_cache import PublicHTMLCache, digest, NoRedirect
|
||||||
|
|
||||||
|
URL = 'https://eccv.ecva.net/virtual/2026/poster/4048'
|
||||||
|
|
||||||
|
|
||||||
|
class PublicHTMLCacheTests(unittest.TestCase):
|
||||||
|
def receipt(self, raw):
|
||||||
|
return {'url':URL,'final_url':URL,'http_status':200,'content_type':'text/html; charset=utf-8',
|
||||||
|
'bytes':len(raw),'sha256':digest(raw),'retrieved_at':datetime.now(timezone.utc).isoformat()}
|
||||||
|
|
||||||
|
def test_old_cache_reused_without_network_or_expiry(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp, 'https://eccv.ecva.net', delay=0); raw = b'<html>metadata</html>'
|
||||||
|
body, receipt, _ = c.paths(URL); body.write_bytes(raw); receipt.write_text(json.dumps(self.receipt(raw))); os.utime(body,(0,0))
|
||||||
|
c.opener = MagicMock(); self.assertEqual(c.get(URL)[0], raw); c.opener.open.assert_not_called()
|
||||||
|
|
||||||
|
def test_pair_tampering_and_orphan_parts_fail_without_refetch(self):
|
||||||
|
for kind in ('hash','orphan','part'):
|
||||||
|
with self.subTest(kind=kind), tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp, 'https://eccv.ecva.net', delay=0); body, receipt, _ = c.paths(URL); body.write_bytes(b'original')
|
||||||
|
if kind == 'hash': receipt.write_text(json.dumps(self.receipt(b'different')))
|
||||||
|
if kind == 'part': body.unlink(); body.with_suffix('.html.part').write_bytes(b'partial')
|
||||||
|
c.opener = MagicMock()
|
||||||
|
with self.assertRaises(ValueError): c.get(URL)
|
||||||
|
c.opener.open.assert_not_called()
|
||||||
|
|
||||||
|
def test_http_access_failure_sticky_without_automatic_retry(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp, 'https://eccv.ecva.net', delay=0); c.opener = MagicMock()
|
||||||
|
c.opener.open.side_effect = urllib.error.HTTPError(URL,403,'Forbidden',{},None)
|
||||||
|
with self.assertRaises(urllib.error.HTTPError): c.get(URL)
|
||||||
|
with self.assertRaisesRegex(ValueError,'Previous access'): c.get(URL)
|
||||||
|
self.assertEqual(c.opener.open.call_count,1)
|
||||||
|
|
||||||
|
def test_redirect_nonhtml_challenge_and_oversize_rejected(self):
|
||||||
|
for kind in ('redirect','type','challenge','size'):
|
||||||
|
with self.subTest(kind=kind), tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp,'https://eccv.ecva.net',limit=100,delay=0); c.opener=MagicMock(); r=c.opener.open.return_value.__enter__.return_value
|
||||||
|
r.status=200; r.geturl.return_value=URL; r.headers={'Content-Type':'text/html'}; r.read.return_value=b'<html>metadata</html>'
|
||||||
|
if kind=='redirect':r.geturl.return_value='https://example.org/login'
|
||||||
|
if kind=='type':r.headers={'Content-Type':'application/pdf'}
|
||||||
|
if kind=='challenge':r.read.return_value=b'<title>Just a moment</title>'
|
||||||
|
if kind=='size':r.read.return_value=b'x'*101
|
||||||
|
with self.assertRaises(ValueError):c.get(URL)
|
||||||
|
self.assertFalse(c.paths(URL)[0].exists())
|
||||||
|
self.assertIsNone(NoRedirect().redirect_request(None,None,None,None,None,None))
|
||||||
|
|
||||||
|
def test_valid_response_has_atomic_body_and_receipt(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c=PublicHTMLCache(tmp,'https://eccv.ecva.net',delay=0);c.opener=MagicMock();r=c.opener.open.return_value.__enter__.return_value;r.status=200;r.geturl.return_value=URL;r.headers={'Content-Type':'text/html','Content-Length':'4'};r.read.return_value=b'data'
|
||||||
|
raw, receipt=c.get(URL);self.assertEqual(raw,b'data');self.assertEqual(receipt['sha256'],digest(raw));self.assertEqual(c.cached(URL),(raw,receipt));self.assertFalse(list(Path(tmp).glob('*.part')))
|
||||||
|
|
||||||
|
def test_foreign_origin_and_cache_symlink_rejected(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c=PublicHTMLCache(tmp,'https://eccv.ecva.net',delay=0)
|
||||||
|
with self.assertRaises(ValueError):c.get('https://example.org/other')
|
||||||
|
body,_,_=c.paths(URL);target=Path(tmp)/'outside';target.write_bytes(b'other');body.symlink_to(target)
|
||||||
|
with self.assertRaises(ValueError):c.get(URL)
|
||||||
|
|
||||||
|
def test_successful_fetch_publishes_receipt_and_reuses_without_refetch(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp, 'https://eccv.ecva.net', delay=0)
|
||||||
|
c.opener = MagicMock(); response = c.opener.open.return_value.__enter__.return_value
|
||||||
|
response.status = 200; response.geturl.return_value = URL
|
||||||
|
raw = b'<html>public metadata</html>'
|
||||||
|
response.headers = {'Content-Type':'text/html','Content-Length':str(len(raw))}; response.read.return_value = raw
|
||||||
|
self.assertEqual(c.get(URL)[0], raw); self.assertEqual(c.get(URL)[0], raw)
|
||||||
|
self.assertEqual(c.opener.open.call_count, 1)
|
||||||
|
body, receipt, _ = c.paths(URL)
|
||||||
|
self.assertTrue(body.exists()); self.assertTrue(receipt.exists())
|
||||||
|
self.assertFalse(body.with_suffix('.html.part').exists())
|
||||||
|
self.assertFalse(receipt.with_suffix('.json.part').exists())
|
||||||
|
|
||||||
|
def test_changed_url_is_rejected_before_reading_body(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
c = PublicHTMLCache(tmp, 'https://eccv.ecva.net', delay=0)
|
||||||
|
c.opener = MagicMock(); response = c.opener.open.return_value.__enter__.return_value
|
||||||
|
response.status = 200; response.geturl.return_value = 'https://example.org/login'
|
||||||
|
response.headers = {'Content-Type':'text/html'}
|
||||||
|
with self.assertRaises(ValueError): c.get(URL)
|
||||||
|
response.read.assert_not_called()
|
||||||
Reference in New Issue
Block a user