webcontentedit: Better checks for vim usage

Using a full path would not detect vim (/usr/bin/vim).
Also, we can detect if EDITOR=vi but the vi is a symlink to vim.
This commit is contained in:
Laurent Bachelier 2014-09-17 21:48:46 +02:00
commit 1150e89b65

View file

@ -21,6 +21,7 @@
import os
import tempfile
import codecs
from distutils.spawn import find_executable
from weboob.core.bcall import CallErrors
from weboob.capabilities.content import CapContent, Revision
@ -73,7 +74,8 @@ class WebContentEdit(ReplApplication):
params = ''
editor = os.environ.get('EDITOR', 'vim')
if editor == 'vim':
# check cases where /usr/bin/vi is a symlink to vim
if 'vim' in (os.path.basename(editor), os.path.basename(os.path.realpath(find_executable(editor) or '/')).replace('.nox', '')):
params = '-p'
os.system("%s %s %s" % (editor, params, ' '.join(['"%s"' % path.replace('"', '\\"') for path in paths.iterkeys()])))