Parse ProjectSettings/ProjectSettings.asset (YAML).
(cls, project_path: Path)
| 109 | |
| 110 | @classmethod |
| 111 | def from_file(cls, project_path: Path) -> ProjectSettings: |
| 112 | """Parse ProjectSettings/ProjectSettings.asset (YAML).""" |
| 113 | settings_file = project_path / "ProjectSettings/ProjectSettings.asset" |
| 114 | |
| 115 | if not settings_file.exists(): |
| 116 | raise ProjectError( |
| 117 | f"ProjectSettings.asset not found: {settings_file}", |
| 118 | code="PROJECT_SETTINGS_NOT_FOUND", |
| 119 | ) |
| 120 | |
| 121 | content = settings_file.read_text(encoding="utf-8") |
| 122 | |
| 123 | def extract_value(key: str, default: str = "") -> str: |
| 124 | match = re.search(rf"{key}:\s*(.+)", content) |
| 125 | return match.group(1).strip() if match else default |
| 126 | |
| 127 | def extract_int(key: str, default: int = 0) -> int: |
| 128 | match = re.search(rf"{key}:\s*(\d+)", content) |
| 129 | return int(match.group(1)) if match else default |
| 130 | |
| 131 | return cls( |
| 132 | product_name=extract_value("productName", "Unknown"), |
| 133 | company_name=extract_value("companyName", "Unknown"), |
| 134 | version=extract_value("bundleVersion", "0.1"), |
| 135 | default_screen_width=extract_int("defaultScreenWidth", 1024), |
| 136 | default_screen_height=extract_int("defaultScreenHeight", 768), |
| 137 | ) |
| 138 | |
| 139 | |
| 140 | @dataclass(frozen=True) |
nothing calls this directly
no test coverage detected