()
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | parser = argparse.ArgumentParser(description="静态筛选原始书源池") |
| 16 | parser.add_argument("--input", "-i", type=Path, help="输入文件,默认使用 pool/raw.json") |
| 17 | parser.add_argument("--output", "-o", type=Path, help="输出文件,默认使用 pool/screened.json") |
| 18 | parser.add_argument("--report", "-r", type=Path, help="报告文件,默认使用 pool/screened_report.json") |
| 19 | args = parser.parse_args() |
| 20 | |
| 21 | legado_dir = resolve_legado_dir(Path(__file__).parent.parent) |
| 22 | inventory = SourceInventory(legado_dir) |
| 23 | |
| 24 | input_file = args.input or raw_pool_file(legado_dir) |
| 25 | output_file = args.output or screened_pool_file(legado_dir) |
| 26 | report_file = args.report or screened_report_file(legado_dir) |
| 27 | |
| 28 | with open(input_file, "r", encoding="utf-8") as f: |
| 29 | sources = json.load(f) |
| 30 | |
| 31 | screened, report = inventory.refresh_screened_pool(sources, save=False) |
| 32 | |
| 33 | output_file.parent.mkdir(parents=True, exist_ok=True) |
| 34 | with open(output_file, "w", encoding="utf-8") as f: |
| 35 | json.dump(screened, f, ensure_ascii=False, indent=2) |
| 36 | |
| 37 | report_file.parent.mkdir(parents=True, exist_ok=True) |
| 38 | with open(report_file, "w", encoding="utf-8") as f: |
| 39 | json.dump(report, f, ensure_ascii=False, indent=2) |
| 40 | |
| 41 | print("静态筛选完成") |
| 42 | print(f"输入数量:{report['input']}") |
| 43 | print(f"通过数量:{report['screened']}") |
| 44 | print(f"剔除数量:{report['rejected']}") |
| 45 | print(f"输出文件:{output_file}") |
| 46 | print(f"报告文件:{report_file}") |
| 47 | |
| 48 | return 0 |
| 49 | |
| 50 | |
| 51 | if __name__ == "__main__": |
no test coverage detected