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

Function process_file

scripts/postprocess_fulltext.py:701–736  ·  view source on GitHub ↗
(path: Path, dry_run: bool)

Source from the content-addressed store, hash-verified

699# ── main processing ───────────────────────────────────────────────────────────
700
701def process_file(path: Path, dry_run: bool) -> dict:
702 original = path.read_text(encoding='utf-8')
703 content = original
704
705 content, toc_removed = remove_toc_tables(content)
706 content, fn_count = reformat_footnotes(content)
707 content, frag_merged = merge_fragmented_tables(content)
708 content, dup_cols_fixed = deduplicate_table_columns(content)
709 content = deduplicate_headers(content)
710
711 content, hdr_removed = cleanup_page_headers_and_cover_images(content)
712 content, lay_fixed = fix_complex_layouts(content)
713 content, specific_fixed = apply_specific_fixes(content)
714 content, bullets_fixed = fix_messy_bullets(content)
715 content, paras_joined = join_split_paragraphs(content)
716
717 content = collapse_blank_lines(content)
718
719 changed = content != original
720 stats = {
721 'toc_removed': toc_removed,
722 'footnotes': fn_count,
723 'frag_merged': frag_merged,
724 'dup_cols_fixed': dup_cols_fixed,
725 'hdr_removed': hdr_removed,
726 'lay_fixed': lay_fixed,
727 'specific_fixed': specific_fixed,
728 'bullets_fixed': bullets_fixed,
729 'paras_joined': paras_joined,
730 'changed': changed,
731 }
732
733 if changed and not dry_run:
734 path.write_text(content, encoding='utf-8')
735
736 return stats
737
738
739def main():

Callers 2

convert_oneFunction · 0.90
mainFunction · 0.70

Calls 11

remove_toc_tablesFunction · 0.85
reformat_footnotesFunction · 0.85
merge_fragmented_tablesFunction · 0.85
deduplicate_headersFunction · 0.85
fix_complex_layoutsFunction · 0.85
apply_specific_fixesFunction · 0.85
fix_messy_bulletsFunction · 0.85
join_split_paragraphsFunction · 0.85
collapse_blank_linesFunction · 0.85

Tested by

no test coverage detected