def open_file_for_editing(file_location): editor = fileoperations.get_editor() if editor: try: os.system(editor + ' ' + file_location) except OSError: io.log_error(prompts['fileopen.error1'].replace( '{editor}', editor)) else: try: os.system(file_location) except OSError: io.log_error(prompts['fileopen.error2'])
def test_get_editor__set_as_environment_variable(self): os.environ['EDITOR'] = 'vim' fileoperations.write_config_setting('global', 'editor', None) self.assertEqual('vim', fileoperations.get_editor()) os.environ['EDITOR'] = ''
def test_get_editor__cant_determine_editor__picks_default__non_windows( self): os.environ['EDITOR'] = '' fileoperations.write_config_setting('global', 'editor', None) self.assertEqual('nano', fileoperations.get_editor())
def test_get_editor__set_as_global(self): os.environ['EDITOR'] = '' fileoperations.write_config_setting('global', 'editor', 'vim') self.assertEqual('vim', fileoperations.get_editor())