| import os
|
| import sys
|
|
|
| def merge_qt_files(project_dir, output_file="master.txt"):
|
|
|
| TARGET_EXTENSIONS = {'.cpp', '.qml', '.cmake', '.qrc','.h','.txt', '.rs', '.wit'}
|
|
|
| TARGET_FILES = {'cmakelists.txt'}
|
|
|
| SKIP_DIRS = {'build','target','dist','out','bin','obj','.git','.svn','.hg','bex-data','.bex-data','plugins', 'CMakeFiles'}
|
|
|
| project_dir = os.path.abspath(project_dir)
|
| print(f"🔍 Scanning: {project_dir}")
|
|
|
| with open(output_file, 'w', encoding='utf-8') as master:
|
| for dirpath, dirnames, filenames in os.walk(project_dir):
|
|
|
| dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS]
|
|
|
| for filename in filenames:
|
| _, ext = os.path.splitext(filename)
|
|
|
| if ext.lower() in TARGET_EXTENSIONS or filename.lower() in TARGET_FILES:
|
| filepath = os.path.join(dirpath, filename)
|
| rel_path = os.path.relpath(filepath, project_dir)
|
|
|
| try:
|
|
|
| with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
|
| content = f.read()
|
| master.write(f"# File: {rel_path}\n")
|
| master.write(content)
|
| master.write("\n\n")
|
| except Exception as e:
|
| master.write(f"# Error reading {rel_path}: {e}\n\n")
|
|
|
| print(f"✅ Done! Merged all files into '{output_file}'.")
|
|
|
| if __name__ == "__main__":
|
|
|
| folder = sys.argv[1] if len(sys.argv) > 1 else "."
|
| merge_qt_files(folder) |