def add_devel_repository(yaml_file, name, vcs_type, url, version='master'): data = yaml.load(open(yaml_file, 'r')) if data['type'] == 'gbp': add_devel_repository_fuerte(yaml_file, data, name, vcs_type, url, version) return if data['type'] != 'distribution': raise RuntimeError('The passed .yaml file is neither of type "distribution" nor "gbp"') if name in data['repositories']: raise RuntimeError('Repository with name "%s" is already in the .yaml file' % name) data['repositories'][name] = { 'source': { 'type': vcs_type, 'url': url, 'version': version } } try: from rosdistro.verify import _to_yaml, _yaml_header_lines except ImportError as e: raise ImportError(str(e) + ' - you need to install the latest version of python-rosdistro.') data = _to_yaml(data) data = '\n'.join(_yaml_header_lines('distribution',1)) + '\n' + data with open(yaml_file, 'w') as f: f.write(data)
def add_devel_repository(yaml_file, name, vcs_type, url, version=None): data = yaml.load(open(yaml_file, 'r')) if data['type'] == 'gbp': add_devel_repository_fuerte(yaml_file, data, name, vcs_type, url, version) return if data['type'] != 'source': raise RuntimeError('The passed .yaml file is neither of type "source" nor "gbp"') if name in data['repositories']: raise RuntimeError('Repository with name "%s" is already in the .yaml file' % name) data['repositories'][name] = { 'type': vcs_type, 'url': url, 'version': version, } try: from rosdistro.verify import _to_yaml, _yaml_header_lines except ImportError as e: raise ImportError(str(e) + ' - you need to install the latest version of python-rosdistro.') data = _to_yaml(data) data = '\n'.join(_yaml_header_lines('source')) + '\n' + data with open(yaml_file, 'w') as f: f.write(data)