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):