Get the download URL for this package. If the package has a direct URL, returns it. If the package has a version requirement (e.g., "14.2.0+20241119"), resolves it through the PlatformIO Registry API. Args: system: Target system (e.g., "windows_
(self, system: Optional[str] = None)
| 176 | description: Optional[str] = None |
| 177 | |
| 178 | def get_download_url(self, system: Optional[str] = None) -> Optional[str]: |
| 179 | """ |
| 180 | Get the download URL for this package. |
| 181 | |
| 182 | If the package has a direct URL, returns it. |
| 183 | If the package has a version requirement (e.g., "14.2.0+20241119"), |
| 184 | resolves it through the PlatformIO Registry API. |
| 185 | |
| 186 | Args: |
| 187 | system: Target system (e.g., "windows_amd64", "linux_x86_64"). |
| 188 | If None, auto-detects from current platform. |
| 189 | |
| 190 | Returns: |
| 191 | Download URL or None if resolution fails. |
| 192 | """ |
| 193 | # If we already have a direct URL, return it |
| 194 | if self.url and ( |
| 195 | self.url.startswith("http://") or self.url.startswith("https://") |
| 196 | ): |
| 197 | return self.url |
| 198 | |
| 199 | # If requirements is a URL, return it |
| 200 | if self.requirements and ( |
| 201 | self.requirements.startswith("http://") |
| 202 | or self.requirements.startswith("https://") |
| 203 | ): |
| 204 | return self.requirements |
| 205 | |
| 206 | # If requirements is a version, resolve through registry |
| 207 | if self.requirements: |
| 208 | # Check if it has semantic versioning operators |
| 209 | has_semver_operator = self.requirements.startswith(("~", "^", "=")) |
| 210 | |
| 211 | # For semver operators, pass None to get latest compatible version |
| 212 | # Otherwise pass the exact version |
| 213 | if has_semver_operator: |
| 214 | # Use latest version (pass None to _resolve_package_url_from_registry) |
| 215 | return _resolve_package_url_from_registry( |
| 216 | self.name, None, self.type, system |
| 217 | ) |
| 218 | else: |
| 219 | # Exact version |
| 220 | return _resolve_package_url_from_registry( |
| 221 | self.name, self.requirements.strip(), self.type, system |
| 222 | ) |
| 223 | |
| 224 | # No resolvable URL found |
| 225 | return None |
| 226 | |
| 227 | |
| 228 | @dataclass |
no test coverage detected