Resolve a framework shorthand name to its URL. Args: framework_name: Framework name like 'arduino', 'espidf', etc. Returns: The URL for the framework, or None if resolution fails.
(self, framework_name: str)
| 1820 | return resolution |
| 1821 | |
| 1822 | def resolve_framework_url(self, framework_name: str) -> Optional[str]: |
| 1823 | """ |
| 1824 | Resolve a framework shorthand name to its URL. |
| 1825 | |
| 1826 | Args: |
| 1827 | framework_name: Framework name like 'arduino', 'espidf', etc. |
| 1828 | |
| 1829 | Returns: |
| 1830 | The URL for the framework, or None if resolution fails. |
| 1831 | """ |
| 1832 | if self._is_url(framework_name): |
| 1833 | return framework_name |
| 1834 | |
| 1835 | # Special case for espidf - it's not in the global frameworks list but is commonly used |
| 1836 | if framework_name == "espidf": |
| 1837 | return "https://github.com/espressif/esp-idf" |
| 1838 | |
| 1839 | # Check cache first |
| 1840 | if self._is_framework_cached(framework_name): |
| 1841 | cached = self._framework_cache[framework_name] |
| 1842 | logger.debug(f"Using cached framework resolution for {framework_name}") |
| 1843 | return cached.url |
| 1844 | |
| 1845 | # Resolve via PlatformIO CLI using typed response |
| 1846 | frameworks_list = self._get_frameworks_list_typed() |
| 1847 | |
| 1848 | if not frameworks_list: |
| 1849 | logger.warning("Failed to get frameworks list from PlatformIO") |
| 1850 | return None |
| 1851 | |
| 1852 | # Find the specific framework |
| 1853 | framework_info: Optional[FrameworkInfo] = None |
| 1854 | for fw in frameworks_list: |
| 1855 | if fw.name == framework_name: |
| 1856 | framework_info = fw |
| 1857 | break |
| 1858 | |
| 1859 | if not framework_info: |
| 1860 | logger.warning(f"Framework not found: {framework_name}") |
| 1861 | return None |
| 1862 | |
| 1863 | # Extract URL from framework data |
| 1864 | url = framework_info.url or framework_info.homepage |
| 1865 | homepage = framework_info.homepage |
| 1866 | platforms = framework_info.platforms |
| 1867 | |
| 1868 | # Cache the resolution |
| 1869 | if not hasattr(self, "_framework_cache"): |
| 1870 | self._framework_cache: dict[str, FrameworkResolution] = {} |
| 1871 | |
| 1872 | self._framework_cache[framework_name] = FrameworkResolution( |
| 1873 | name=framework_name, |
| 1874 | url=url, |
| 1875 | homepage=homepage, |
| 1876 | platforms=platforms, |
| 1877 | resolved_at=datetime.now(), |
| 1878 | ) |
| 1879 |