Ejemplo n.º 1
0
def edit_in_editor(initial, remove_newline_at_eof=False):
    editor = os.getenv('VISUAL') or os.getenv('EDITOR') or '/usr/bin/vi'
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(initial or '')
        f.flush()
        pty.spawn([editor, f.name])
        with open(f.name, 'r') as f2:
            return f2.read().rstrip() if remove_newline_at_eof else f2.read()
Ejemplo n.º 2
0
def edit_in_editor(initial, remove_newline_at_eof=False):
    editor = os.getenv('VISUAL') or os.getenv('EDITOR') or '/usr/bin/vi'
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(initial or '')
        f.flush()
        pty.spawn([editor, f.name])
        with open(f.name, 'r') as f2:
            return f2.read().rstrip() if remove_newline_at_eof else f2.read()
Ejemplo n.º 3
0
Archivo: utils.py Proyecto: 650elx/cli
def edit_in_editor(initial):
    editor = os.getenv('VISUAL') or os.getenv('EDITOR') or '/usr/bin/vi'
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(initial or '')
        f.flush()
        pty.spawn([editor, f.name])
        with open(f.name, 'r') as f2:
            return f2.read()