first commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""列出待截图 / 已截图的功能页,供截图流程驱动。
|
||||
用法:
|
||||
python scripts/shot_queue.py # 列出所有 level2 页面(JSON)
|
||||
python scripts/shot_queue.py --pending # 只列出截图文件尚不存在的页面
|
||||
"""
|
||||
import os, json, sqlite3, sys
|
||||
|
||||
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
DB = os.path.join(BASE, "db", "research.db")
|
||||
|
||||
|
||||
def main():
|
||||
pending = "--pending" in sys.argv
|
||||
conn = sqlite3.connect(DB)
|
||||
conn.row_factory = sqlite3.Row
|
||||
rows = [dict(r) for r in conn.execute(
|
||||
"SELECT name, full_path, url, screenshot_path FROM features "
|
||||
"WHERE level=2 ORDER BY sort_order, id").fetchall()]
|
||||
conn.close()
|
||||
out = []
|
||||
for r in rows:
|
||||
rel = r["screenshot_path"]
|
||||
ap = os.path.join(BASE, rel) if rel else ""
|
||||
exists = bool(ap) and os.path.isfile(ap)
|
||||
if pending and exists:
|
||||
continue
|
||||
out.append({
|
||||
"name": r["name"], "full_path": r["full_path"], "url": r["url"],
|
||||
"rel": rel, "abs": ap.replace("\\", "/"), "exists": exists,
|
||||
})
|
||||
print(json.dumps({"count": len(out), "pages": out}, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user