evaluate server list against file names to determine remote server name
This commit is contained in:
parent
cae6118e1d
commit
fd51fcac51
@ -4,7 +4,7 @@ import sys
|
|||||||
config = {
|
config = {
|
||||||
# path to directory containing vim.exe and gvim.exe
|
# path to directory containing vim.exe and gvim.exe
|
||||||
'vimdir': 'C:\\apps\\Vim\\vim73',
|
'vimdir': 'C:\\apps\\Vim\\vim73',
|
||||||
# list of (name, path) tuples defining gvim contexts
|
# list of (path, name) tuples defining gvim contexts
|
||||||
'servers': [],
|
'servers': [],
|
||||||
# default server name to use if no server paths match
|
# default server name to use if no server paths match
|
||||||
'default_server': 'GVIM',
|
'default_server': 'GVIM',
|
||||||
@ -27,7 +27,25 @@ def read_config_file(config, path):
|
|||||||
sys.stderr.write(' File "%s", line %d, in %s\n'
|
sys.stderr.write(' File "%s", line %d, in %s\n'
|
||||||
% (path, lineno, fn))
|
% (path, lineno, fn))
|
||||||
|
|
||||||
|
def path_contains_file(path, fname):
|
||||||
|
path = path.replace('\\', '/')
|
||||||
|
fname = fname.replace('\\', '/')
|
||||||
|
if path.endswith('/'):
|
||||||
|
path = path[:-1]
|
||||||
|
return fname.startswith(path + '/')
|
||||||
|
|
||||||
def get_server_name(config, fname):
|
def get_server_name(config, fname):
|
||||||
|
for path, name in config['servers']:
|
||||||
|
path = path.replace('\\', '/')
|
||||||
|
if path.endswith('/*'):
|
||||||
|
path = path[:-2]
|
||||||
|
for dirent in os.listdir(path):
|
||||||
|
query_path = os.path.join(path, dirent)
|
||||||
|
if os.path.isdir(query_path) and path_contains_file(query_path, fname):
|
||||||
|
return name.replace('*', dirent)
|
||||||
|
else:
|
||||||
|
if path_contains_file(path, fname):
|
||||||
|
return name.replace('*', os.path.basename(path))
|
||||||
return config['default_server']
|
return config['default_server']
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user