mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
- core: added new _editor_command function
Used by "run_editor" and "_edit_message_open_editor" to retrieve the editor command.
This commit is contained in:
parent
132a2d128f
commit
aacbf6a03b
10
osc/core.py
10
osc/core.py
@ -3480,18 +3480,22 @@ def run_pager(message, tmp_suffix=''):
|
|||||||
tmpfile.close()
|
tmpfile.close()
|
||||||
|
|
||||||
def run_editor(filename):
|
def run_editor(filename):
|
||||||
|
cmd = _editor_command()
|
||||||
|
cmd.append(filename)
|
||||||
|
return run_external(cmd[0], *cmd[1:])
|
||||||
|
|
||||||
|
def _editor_command():
|
||||||
editor = os.getenv('EDITOR', default=get_default_editor())
|
editor = os.getenv('EDITOR', default=get_default_editor())
|
||||||
try:
|
try:
|
||||||
cmd = shlex.split(editor)
|
cmd = shlex.split(editor)
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
cmd = editor.split()
|
cmd = editor.split()
|
||||||
cmd.append(filename)
|
return cmd
|
||||||
return run_external(cmd[0], *cmd[1:])
|
|
||||||
|
|
||||||
def _edit_message_open_editor(filename, data, orig_mtime):
|
def _edit_message_open_editor(filename, data, orig_mtime):
|
||||||
# FIXME: import modules globally
|
# FIXME: import modules globally
|
||||||
import tempfile
|
import tempfile
|
||||||
editor = os.getenv('EDITOR', default=get_default_editor()).split(' ')
|
editor = _editor_command()
|
||||||
mtime = os.stat(filename).st_mtime
|
mtime = os.stat(filename).st_mtime
|
||||||
if mtime == orig_mtime:
|
if mtime == orig_mtime:
|
||||||
# prepare file for editors
|
# prepare file for editors
|
||||||
|
Loading…
Reference in New Issue
Block a user