MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / main

Function main

scripts/postprocess_fulltext.py:739–773  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

737
738
739def main():
740 parser = argparse.ArgumentParser(description='Post-process docling fulltext Markdown files')
741 parser.add_argument('--dry-run', action='store_true', help='Show what would change without writing')
742 parser.add_argument('--file', help='Process a single file (basename, e.g. mdcg-2020-5.md)')
743 args = parser.parse_args()
744
745 if args.file:
746 files = [FULLTEXT_DIR / args.file]
747 else:
748 files = sorted(FULLTEXT_DIR.glob('*.md'))
749
750 total_toc = 0
751 total_fn = 0
752 total_frag = 0
753 total_dup = 0
754 changed_count = 0
755
756 for path in files:
757 stats = process_file(path, dry_run=args.dry_run)
758 prefix = '[DRY]' if args.dry_run else '[OK] '
759 if stats['changed']:
760 changed_count += 1
761 print(f"{prefix} {path.name}: removed {stats['toc_removed']} TOC, "
762 f"reformatted {stats['footnotes']} footnotes, "
763 f"merged {stats['frag_merged']} frag-tables, "
764 f"fixed {stats['dup_cols_fixed']} dup-col tables")
765 total_toc += stats['toc_removed']
766 total_fn += stats['footnotes']
767 total_frag += stats['frag_merged']
768 total_dup += stats['dup_cols_fixed']
769
770 mode = 'DRY RUN' if args.dry_run else 'DONE'
771 print(f"\n{mode}: {changed_count}/{len(files)} files changed, "
772 f"{total_toc} TOC removed, {total_fn} footnotes, "
773 f"{total_frag} frag-tables merged, {total_dup} dup-col fixed")
774
775
776if __name__ == '__main__':

Callers 1

Calls 1

process_fileFunction · 0.70

Tested by

no test coverage detected