def _generic_rosed(vim_func, package_name, *file_names): """ Helper method to edit a file using a specific `vim_func`. Arguments --------- vim_func: Reference to a function defined in the `vimp` module. """ try: pkg = rosp.Package(package_name) except rospkg.ResourceNotFound: print('Package {0} not found'.format(package_name)) return for fn in file_names: files = list(pkg.locate_files(fn)) if len(files) == 0: print('File {0} not found'.format(fn)) elif len(files) == 1: vim_func(files[0]) else: f = vimp.inputlist('You have chosen a non-unique filename, please ' 'pick one of the following:', files) if f is not None: vim_func(f)
def _generic_rosed(vim_func, package_name, *file_names): """ Helper method to edit a file using a specific `vim_func`. Arguments --------- vim_func: Reference to a function defined in the `vimp` module. """ try: pkg = rosp.Package(package_name) except rospkg.ResourceNotFound: print('Package {0} not found'.format(package_name)) return for fn in file_names: files = list(pkg.locate_files(fn)) if len(files) == 0: print('File {0} not found'.format(fn)) elif len(files) == 1: vim_func(files[0]) else: f = vimp.inputlist( 'You have chosen a non-unique filename, please ' 'pick one of the following:', files) if f is not None: vim_func(f)
def rosed(package_name, *file_names): try: pkg = rosp.Package(package_name) except rospkg.ResourceNotFound: print("Package {0} not found".format(package_name)) return for fn in file_names: files = list(pkg.locate_files(fn)) if len(files) == 0: print("File {0} not found".format(fn)) elif len(files) == 1: vimp.edit(files[0]) else: f = vimp.inputlist("You have chosen a non-unique filename, please " "pick one of the following:", files) if f is not None: vimp.edit(f)
def rosed(package_name, *file_names): try: pkg = rosp.Package(package_name) except rospkg.ResourceNotFound: print('Package {0} not found'.format(package_name)) return for fn in file_names: files = list(pkg.locate_files(fn)) if len(files) == 0: print('File {0} not found'.format(fn)) elif len(files) == 1: vimp.edit(files[0]) else: f = vimp.inputlist('You have chosen a non-unique filename, please ' 'pick one of the following:', files) if f is not None: vimp.edit(f)