From 845542c469aaca0db1920568b6530b012a797ea6 Mon Sep 17 00:00:00 2001 From: "Hunter L. Allen" Date: Fri, 2 Jun 2017 14:05:17 -0700 Subject: [PATCH] Made the approach more general, also added support for BitBucket. ros-infrastructure/rosdistro#101 ros/ros-overlay#30 --- src/rosdistro/rosdistro.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/rosdistro/rosdistro.py b/src/rosdistro/rosdistro.py index ba68cdf5a..c8bba47ad 100644 --- a/src/rosdistro/rosdistro.py +++ b/src/rosdistro/rosdistro.py @@ -224,30 +224,21 @@ def _fetch_package_xml(self, rosdistro): self._release_tags[rosdistro] = release_tag return package_xml, release_tag else: + release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version) for nongithub in supported_non_githubs: + url = repo.url try: - if nongithub == 'gitlab': - """ - GitLab - """ - info('Trying to fetch non-github repository as a GitLab instance...') - url = repo.url - release_tag = 'release/{0}/{1}/{2}'.format(rosdistro, self.name, repo.version) - url = url.replace('.git', '/raw/{0}/package.xml'.format(release_tag)) - elif nongithub == 'bitbucket': - """ - BitBucket - """ - raise RuntimeError('todo: bitbucket support') + url = url.replace('.git', { + 'gitlab' : '/raw/{0}/package.xml', + 'bitbucket' : '/raw/{0}/package.xml' + }[nongithub].format(release_tag)) package_xml = urlopen(url).read() self._package_xmls[rosdistro] = package_xml self._release_tags[rosdistro] = release_tag return package_xml, release_tag - except Exception as e: - info('Package is not in a {0} repo...'.format({ - 'gitlab' : 'GitLab', - 'bitbucket' : 'BitBucket' - }[nongithub])) + except Exception as e: + # If we get here, try the next one. + pass raise Exception('Failed to identify non-github repository type!') def get_package_xml(self, rosdistro):