-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvalidate_lazy_linux_tool_installer.py
More file actions
99 lines (82 loc) · 3.27 KB
/
validate_lazy_linux_tool_installer.py
File metadata and controls
99 lines (82 loc) · 3.27 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
"""
Quick validation script for Lazy-Linux-Tool-Installer.py
Checks code structure and basic functionality without running full tests.
"""
import importlib.util
import os
import sys
def validate_module():
"""Validate the module can be imported and has required components."""
print("Validating Lazy-Linux-Tool-Installer.py...")
# Load module
script_path = os.path.join(os.path.dirname(__file__), "Lazy-Linux-Tool-Installer.py")
if not os.path.exists(script_path):
print(f"Error: {script_path} not found!")
return False
spec = importlib.util.spec_from_file_location(
"lazy_linux_tool_installer",
script_path
)
dlt = importlib.util.module_from_spec(spec)
spec.loader.exec_module(dlt)
errors = []
warnings = []
# Check required classes exist
required_classes = ['SystemChecker', 'Installer', 'ToolManager', 'Tool', 'InstallMethod']
for cls_name in required_classes:
if not hasattr(dlt, cls_name):
errors.append(f"Missing class: {cls_name}")
else:
print(f"✓ Found class: {cls_name}")
# Check ToolManager has TOOLS
if hasattr(dlt.ToolManager, 'TOOLS'):
tool_count = len(dlt.ToolManager.TOOLS)
print(f"✓ Found {tool_count} tools in TOOLS dictionary")
# Validate each tool
for name, tool in dlt.ToolManager.TOOLS.items():
if not isinstance(tool, dlt.Tool):
errors.append(f"Tool '{name}' is not a Tool instance")
continue
# Check required fields
if not tool.name:
errors.append(f"Tool '{name}' missing name")
if not tool.command:
errors.append(f"Tool '{name}' missing command")
if not tool.method:
errors.append(f"Tool '{name}' missing method")
if not tool.package:
errors.append(f"Tool '{name}' missing package")
if not tool.description:
warnings.append(f"Tool '{name}' missing description")
if not tool.category:
warnings.append(f"Tool '{name}' missing category")
# Check eget tools have github_repo
if tool.method == dlt.InstallMethod.EGET and not tool.github_repo:
errors.append(f"Tool '{name}' uses EGET but missing github_repo")
else:
errors.append("ToolManager.TOOLS not found")
# Check functions exist
required_functions = ['get_user_consent', 'update_package_lists', 'main']
for func_name in required_functions:
if not hasattr(dlt, func_name):
errors.append(f"Missing function: {func_name}")
else:
print(f"✓ Found function: {func_name}")
# Summary
print("\n" + "="*70)
if errors:
print(f"❌ Found {len(errors)} errors:")
for error in errors:
print(f" - {error}")
else:
print("✓ No errors found!")
if warnings:
print(f"\n⚠ Found {len(warnings)} warnings:")
for warning in warnings:
print(f" - {warning}")
print("="*70)
return len(errors) == 0
if __name__ == '__main__':
success = validate_module()
sys.exit(0 if success else 1)