distro_to_rosinstall.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #! /usr/bin/env python
  2. import os
  3. import sys
  4. import yaml
  5. from rospkg.distro import load_distro, distro_uri
  6. def translate(distro, translate_dir):
  7. d = load_distro(distro_uri(distro))
  8. repo_list = d.get_stacks(True)
  9. for name, item in repo_list.iteritems():
  10. if item.vcs_config.type == 'svn':
  11. rosinstall = [{item.vcs_config.type: \
  12. {'local-name': item.name,
  13. 'uri': item.vcs_config.anon_dev}}]
  14. else:
  15. rosinstall = [{item.vcs_config.type: \
  16. {'local-name': item.name,
  17. 'uri': item.vcs_config.anon_repo_uri,
  18. 'version': item.vcs_config.dev_branch}}]
  19. path = os.path.join(translate_dir, "%s.rosinstall" % item.name)
  20. with open(path, 'w+') as f:
  21. print("writing to %s" % path)
  22. yaml.safe_dump(rosinstall, f, default_flow_style=False)
  23. if __name__ == '__main__':
  24. if len(sys.argv) != 3:
  25. print("Use %s distro install_folder" % sys.argv[0])
  26. sys.exit()
  27. translate(sys.argv[1], sys.argv[2])