Skip to content

Commit c37decc

Browse files
committed
distro: add manifest download helper
Return either cached version or attempt download and return result.
1 parent 43ba58a commit c37decc

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

vinca/distro.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ def get_package_xml_for_additional_package(self, pkg_info):
216216
except Exception as e:
217217
raise RuntimeError(f"Failed to fetch package.xml from {raw_url}: {e}")
218218

219+
def _download_raw_pkg_xml_or_cached(self, url):
220+
if url in self._additional_xml_cache:
221+
return self._additional_xml_cache[url]
222+
try:
223+
with urllib.request.urlopen(url) as resp:
224+
xml_content = resp.read().decode("utf-8")
225+
self._additional_xml_cache[url] = xml_content
226+
return xml_content
227+
except Exception as e:
228+
raise RuntimeError(f"Failed to fetch package.xml from {url}: {e}")
229+
219230
# Based on https://github.com/ros-infrastructure/rosdistro/blob/fad8d9f647631945847cb18bc1d1f43008d7a282/src/rosdistro/manifest_provider/github.py#L51C1-L69C29
220231
# But with the option to specify the name of the package.xml file in case the repo uses a non-standard name
221232
def _construct_raw_url_github(self, pkg_info):

0 commit comments

Comments
 (0)