Python editor.edit() Examples
The following are 9
code examples of editor.edit().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
editor
, or try the search function
.
Example #1
Source File: pyfiles.py From jbox with MIT License | 5 votes |
def edit(path): """Given a source path, run the EDITOR for it""" import editor try: editor.edit(path) except Exception as exc: raise CommandError('Error executing editor (%s)' % (exc,))
Example #2
Source File: pyfiles.py From alembic with MIT License | 5 votes |
def edit(path): """Given a source path, run the EDITOR for it""" import editor try: editor.edit(path) except Exception as exc: raise CommandError("Error executing editor (%s)" % (exc,))
Example #3
Source File: cli.py From chepy with GNU General Public License v3.0 | 5 votes |
def cli_edit_state(fire: object, args: list): """Edit the current state Args: args (object): Cli args """ current_index = fire._current_index hold = editor.edit(contents=str(fire.states[current_index])).decode() args[current_index] = hold
Example #4
Source File: save_engine.py From raisetheempires with GNU General Public License v3.0 | 5 votes |
def exception_handler(exc_type, exc_value, exc_traceback): if issubclass(exc_type, KeyboardInterrupt): sys.__excepthook__(exc_type, exc_value, exc_traceback) return logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)) if crash_log: text = editor.edit(filename=os.path.join(log_path(), "log.txt")) # logger = logging.getLogger(__name__) # handler = logging.StreamHandler(stream=sys.stdout) # logger.addHandler(handler)
Example #5
Source File: empires-server.py From raisetheempires with GNU General Public License v3.0 | 5 votes |
def save_savegame(): print("Going to save:") restores = [int(key[7:]) for key in request.form.keys() if "restore" in key] if restores: save_game = session["backup"] for i in range(restores[0]): save_game = save_game["backup"] save_game = copy.deepcopy(save_game) print("restoring backup") message = "Revert to backup \"" + format_backup_message(save_game) + "\"" else: save_game = json.loads(request.form['savegame']) message = "before " + request.form.get("message") print(repr(save_game)) create_backup(message) session['saved'] = str(session.get('saved', "")) + "edit" session['user_object'] = save_game['user_object'] session['quests'] = save_game['quests'] session['battle'] = save_game['battle'] session['fleets'] = save_game['fleets'] session['population'] = save_game['population'] session['save_version'] = save_game['save_version'] response = make_response(redirect('/home.html')) return response # return ('', 400)
Example #6
Source File: empires-server.py From raisetheempires with GNU General Public License v3.0 | 5 votes |
def server_error_page(error): if crash_log: text = editor.edit(filename=os.path.join(log_path(), "log.txt")) return 'It went wrong'
Example #7
Source File: pack.py From st2 with Apache License 2.0 | 5 votes |
def run(self, args, **kwargs): schema = self.app.client.managers['ConfigSchema'].get_by_ref_or_id(args.name, **kwargs) if not schema: msg = '%s "%s" doesn\'t exist or doesn\'t have a config schema defined.' raise resource.ResourceNotFoundError(msg % (self.resource.get_display_name(), args.name)) config = interactive.InteractiveForm(schema.attributes).initiate_dialog() message = '---\nDo you want to preview the config in an editor before saving?' description = 'Secrets will be shown in plain text.' preview_dialog = interactive.Question(message, {'default': 'y', 'description': description}) if preview_dialog.read() == 'y': try: contents = yaml.safe_dump(config, indent=4, default_flow_style=False) modified = editor.edit(contents=contents) config = yaml.safe_load(modified) except editor.EditorError as e: print(six.text_type(e)) message = '---\nDo you want me to save it?' save_dialog = interactive.Question(message, {'default': 'y'}) if save_dialog.read() == 'n': raise OperationFailureException('Interrupted') config_item = Config(pack=args.name, values=config) result = self.app.client.managers['Config'].update(config_item, **kwargs) return result
Example #8
Source File: _editor.py From python-inquirer with MIT License | 5 votes |
def process_input(self, pressed): if pressed == key.CTRL_C: raise KeyboardInterrupt() if pressed in (key.CR, key.LF, key.ENTER): data = editor.edit(contents=self.question.default or '') raise errors.EndOfInput(data.decode('utf-8')) raise errors.ValidationError('You have pressed unknown key! ' 'Press <enter> to open editor or ' 'CTRL+C to exit.')
Example #9
Source File: pyfiles.py From android_universal with MIT License | 5 votes |
def edit(path): """Given a source path, run the EDITOR for it""" import editor try: editor.edit(path) except Exception as exc: raise CommandError('Error executing editor (%s)' % (exc,))