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 # Clean up any leftover .py files (keep only __init__.py) 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