當前位置: 首頁>>代碼示例>>Python>>正文


Python editor.edit方法代碼示例

本文整理匯總了Python中editor.edit方法的典型用法代碼示例。如果您正苦於以下問題:Python editor.edit方法的具體用法?Python editor.edit怎麽用?Python editor.edit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在editor的用法示例。


在下文中一共展示了editor.edit方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: edit

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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,)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:10,代碼來源:pyfiles.py

示例2: edit

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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,)) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:11,代碼來源:pyfiles.py

示例3: cli_edit_state

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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 
開發者ID:securisec,項目名稱:chepy,代碼行數:11,代碼來源:cli.py

示例4: exception_handler

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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) 
開發者ID:AcidCaos,項目名稱:raisetheempires,代碼行數:14,代碼來源:save_engine.py

示例5: save_savegame

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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) 
開發者ID:AcidCaos,項目名稱:raisetheempires,代碼行數:31,代碼來源:empires-server.py

示例6: server_error_page

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
def server_error_page(error):
    if crash_log:
        text = editor.edit(filename=os.path.join(log_path(), "log.txt"))
    return 'It went wrong' 
開發者ID:AcidCaos,項目名稱:raisetheempires,代碼行數:6,代碼來源:empires-server.py

示例7: run

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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 
開發者ID:StackStorm,項目名稱:st2,代碼行數:33,代碼來源:pack.py

示例8: process_input

# 需要導入模塊: import editor [as 別名]
# 或者: from editor import edit [as 別名]
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.') 
開發者ID:magmax,項目名稱:python-inquirer,代碼行數:13,代碼來源:_editor.py


注:本文中的editor.edit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。