Coverage for scripts/copy_readme.py: 0%
24 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:22 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:22 +0000
1import sys
3def copy_markdown_lines(source_file, target_file, start_line=15):
4 try:
5 # Read source file
6 with open(source_file, 'r', encoding='utf-8') as src:
7 source_lines = src.readlines()
9 # Check if source file has enough lines
10 if len(source_lines) < start_line:
11 print(f"Error: Source file '{source_file}' has fewer than {start_line} lines.")
12 sys.exit(1)
14 with open(target_file, 'r', encoding='utf-8') as dst:
15 dest_lines = dst.readlines()
17 content_to_copy = dest_lines[:start_line] + source_lines[start_line + 1:-5]
19 # Write to target file
20 with open(target_file, 'w', encoding='utf-8') as tgt:
21 tgt.writelines(content_to_copy)
23 print(f"Successfully copied content from '{source_file}' (line {start_line} onward) to '{target_file}'.")
25 except FileNotFoundError as e:
26 print(f"Error: File not found - {e}")
27 sys.exit(1)
28 except Exception as e:
29 print(f"Error: {e}")
30 sys.exit(1)
32if __name__ == "__main__":
33 source_file = "./README.md" # Path to the source file
34 target_file = "./doxyfiles/doxyfile_readme.md" # Path to the target file
35 copy_markdown_lines(source_file, target_file)