mirror of
https://github.com/cosmo-sims/cosmICweb-music.git
synced 2024-09-18 15:43:45 +02:00
only run vim-specific arguments with vim
This commit is contained in:
parent
33d12b3082
commit
e011150809
2 changed files with 8 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
__pycache__
|
||||
.venv
|
||||
dist
|
||||
*.cfg
|
||||
|
|
|
@ -22,6 +22,7 @@ logger.setLevel("INFO")
|
|||
# Some constants
|
||||
DEFAULT_URL = "https://cosmicweb.eu"
|
||||
EDITOR = os.environ.get("EDITOR", "vim")
|
||||
EDITOR_IS_VIM = EDITOR in {"vim", "nvim"}
|
||||
|
||||
|
||||
# Types
|
||||
|
@ -181,11 +182,14 @@ def fetch_publication(cosmicweb_url, publication_name, traceback_radius):
|
|||
|
||||
|
||||
def edit_template(template):
|
||||
with tempfile.NamedTemporaryFile(suffix=".tmp", mode="r+") as tf:
|
||||
with tempfile.NamedTemporaryFile(suffix=".tmp.conf", mode="r+") as tf:
|
||||
tf.write(template)
|
||||
tf.flush()
|
||||
# Call the editor. backupcopy=yes prevents vim from creating copy and rename
|
||||
subprocess.call([EDITOR, "+set backupcopy=yes", tf.name])
|
||||
editor_parameters = []
|
||||
if EDITOR_IS_VIM:
|
||||
# backupcopy=yes prevents vim from creating copy and rename
|
||||
editor_parameters.append("+set backupcopy=yes")
|
||||
subprocess.call([EDITOR] + editor_parameters + [tf.name])
|
||||
tf.seek(0)
|
||||
template = tf.read()
|
||||
return template
|
||||
|
|
Loading…
Reference in a new issue