-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.py
More file actions
35 lines (27 loc) · 1.04 KB
/
Copy pathtool.py
File metadata and controls
35 lines (27 loc) · 1.04 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
"""Data model representing the result of checking a single development tool."""
from dataclasses import dataclass
from enum import Enum
from typing import Optional
class ToolStatus(Enum):
"""Possible states a checked tool can be in."""
INSTALLED = "Installed"
NOT_INSTALLED = "Not Installed"
VERSION_UNAVAILABLE = "Installed but version unavailable"
@dataclass
class ToolResult:
"""Holds the outcome of checking a single tool on the system."""
name: str
status: ToolStatus
version: Optional[str] = None
path: Optional[str] = None
error: Optional[str] = None
def to_dict(self) -> dict:
"""Convert this result into a plain dictionary suitable for JSON/CSV export."""
return {
"tool": self.name,
"installed": self.status != ToolStatus.NOT_INSTALLED,
"status": self.status.value,
"version": self.version if self.version else "-",
"path": self.path if self.path else "-",
"error": self.error if self.error else "",
}