| | import os |
| |
|
| |
|
| | def setup_testing_space(): |
| | """Create persistent testing_space directory and __init__.py at startup.""" |
| | testing_dir = os.path.join(os.getcwd(), "inputs") |
| | os.makedirs(testing_dir, exist_ok=True) |
| |
|
| | init_file = os.path.join(testing_dir, "__init__.py") |
| | if not os.path.exists(init_file): |
| | with open(init_file, "w", encoding="utf-8") as f: |
| | f.write("# Testing space for py2puml analysis\n") |
| | print("๐ Created testing_space directory and __init__.py") |
| | else: |
| | print("๐ testing_space directory already exists") |
| |
|
| |
|
| | def cleanup_testing_space(): |
| | """Remove all .py files except __init__.py from testing_space.""" |
| | testing_dir = os.path.join(os.getcwd(), "inputs") |
| | if not os.path.exists(testing_dir): |
| | print("โ ๏ธ testing_space directory not found, creating it...") |
| | setup_testing_space() |
| | return |
| |
|
| | |
| | files_removed = 0 |
| | for file in os.listdir(testing_dir): |
| | if file.endswith(".py") and file != "__init__.py": |
| | file_path = os.path.join(testing_dir, file) |
| | try: |
| | os.remove(file_path) |
| | files_removed += 1 |
| | except Exception as e: |
| | print(f"โ ๏ธ Could not remove {file}: {e}") |
| |
|
| | if files_removed > 0: |
| | print(f"๐งน Cleaned up {files_removed} leftover .py files from testing_space") |
| |
|
| |
|
| | def verify_testing_space(): |
| | """Verify testing_space contains only __init__.py.""" |
| | testing_dir = os.path.join(os.getcwd(), "inputs") |
| | if not os.path.exists(testing_dir): |
| | return False |
| |
|
| | files = os.listdir(testing_dir) |
| | expected_files = ["__init__.py"] |
| |
|
| | return files == expected_files |
| |
|