File size: 1,743 Bytes
ef444e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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