read config file
This commit is contained in:
parent
665209bb33
commit
f7784fc76a
@ -1,12 +1,32 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
GVIM_PATH = 'C:\\apps\\Vim\\vim73\\gvim.exe'
|
||||
config = {
|
||||
'vimdir': 'C:\\apps\\Vim\\vim73'
|
||||
}
|
||||
|
||||
def read_config_file(config, path):
|
||||
if os.path.exists(path):
|
||||
fh = open(path, 'r')
|
||||
script = fh.read()
|
||||
fh.close()
|
||||
try:
|
||||
exec(script, config)
|
||||
except:
|
||||
sys.stderr.write('Configuration file error in "%s":\n' % path)
|
||||
traceback.print_exception(sys.exc_info()[0], sys.exc_info()[1],
|
||||
None)
|
||||
tb = traceback.extract_tb(sys.exc_info()[2])
|
||||
for ent in tb[1:]:
|
||||
lineno, fn = ent[1:3]
|
||||
sys.stderr.write(' File "%s", line %d, in %s\n'
|
||||
% (path, lineno, fn))
|
||||
|
||||
def main(argv):
|
||||
if (len(argv) < 2):
|
||||
return -1
|
||||
os.execv(GVIM_PATH, ['gvim', '--remote-tab-silent'] + argv[1:])
|
||||
read_config_file(config, os.path.expanduser('~/.gvim-wrapper'))
|
||||
os.execv(config['vimdir'] + '\\gvim.exe', ['gvim', '--remote-tab-silent'] + argv[1:])
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
Loading…
x
Reference in New Issue
Block a user