@@ -18,6 +18,11 @@ def parse_args():
1818 parser .add_argument ("--pgurl" , default = stub_doc .DEFAULT_PGURL , help = "PostgreSQL connection URL" )
1919 parser .add_argument ("--stub-dir" , default = REPO_ROOT / "stub" , type = Path , help = "English stub directory" )
2020 parser .add_argument ("--zh-stub-dir" , default = REPO_ROOT / "stub-zh" , type = Path , help = "Chinese stub directory" )
21+ parser .add_argument (
22+ "--dry-run" ,
23+ action = "store_true" ,
24+ help = "run every database assertion and write in a transaction, then roll it back" ,
25+ )
2126 return parser .parse_args ()
2227
2328
@@ -26,7 +31,11 @@ def warn_extra(label: str, names):
2631 return
2732 preview = ", " .join (names [:10 ])
2833 suffix = "" if len (names ) <= 10 else f", ... (+{ len (names ) - 10 } more)"
29- print (f"warning: { len (names )} { label } files do not match pgext.extension rows: { preview } { suffix } " , file = sys .stderr )
34+ print (
35+ f"warning: { len (names )} { label } files do not match "
36+ f"pgext.universe4 rows: { preview } { suffix } " ,
37+ file = sys .stderr ,
38+ )
3039
3140
3241def main () -> int :
@@ -35,13 +44,14 @@ def main() -> int:
3544 zh_docs = stub_doc .collect_stub_docs (args .zh_stub_dir )
3645
3746 with stub_doc .connect (args .pgurl ) as conn :
38- stats = stub_doc .load_stub_docs (conn , en_docs , zh_docs )
47+ stats = stub_doc .load_stub_docs (conn , en_docs , zh_docs , dry_run = args . dry_run )
3948
4049 warn_extra ("English stub" , stats ["extra_en" ])
4150 warn_extra ("Chinese stub" , stats ["extra_zh" ])
51+ action = "validated" if stats ["dry_run" ] else "loaded"
4252 print (
43- "loaded pgext.doc: "
44- f"base_rows ={ stats ['base_rows' ]} "
53+ f" { action } pgext.doc: "
54+ f"universe_rows ={ stats ['base_rows' ]} "
4555 f"en_doc={ stats ['en_doc' ]} "
4656 f"zh_doc={ stats ['zh_doc' ]} "
4757 f"missing_en={ len (stats ['missing_en' ])} "
0 commit comments