From 54363e9636394464bbdaa54934f333b5239ed9bc Mon Sep 17 00:00:00 2001 From: "alex.boterolowry" Date: Fri, 13 Nov 2009 23:36:40 +0000 Subject: use shlex.split instead of string.split git-svn-id: http://freebase-python.googlecode.com/svn/trunk@229 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2 --- freebase/fcl/commands.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/freebase/fcl/commands.py b/freebase/fcl/commands.py index c42d4cb..decc3cc 100755 --- a/freebase/fcl/commands.py +++ b/freebase/fcl/commands.py @@ -276,19 +276,23 @@ def cmd_cat(fb, id, include_headers=False): def cmd_shell(fb): import readline + import shlex def complete_cmd(text, state): - return '' + m = [ c for c in fb.commands if c.startswith(text) ] + return m[state] + readline.set_completer(complete_cmd) -# readline.parse_and_bind('tab: complete') - graphs = {'http://trunk.qa.metaweb.com':'qa', - 'http://branch.qa.metaweb.com':'qa', - 'http://www.freebase.com':'otg', - 'http://api.freebase.com':'otg', - 'http://freebase.com':'otg', - 'http://www.sandbox-freebase.com':'sandbox', - 'http://api.sandbox-freebase.com':'sandbox', - 'http://sandbox-freebase.com':'sandbox' - } + readline.parse_and_bind('tab: complete') + graphs = { + 'http://trunk.qa.metaweb.com':'qa', + 'http://branch.qa.metaweb.com':'qa', + 'http://www.freebase.com':'otg', + 'http://api.freebase.com':'otg', + 'http://freebase.com':'otg', + 'http://www.sandbox-freebase.com':'sandbox', + 'http://api.sandbox-freebase.com':'sandbox', + 'http://sandbox-freebase.com':'sandbox' + } gname = graphs.get(fb.mss.service_url, 'unknown') while True: @@ -299,7 +303,7 @@ def cmd_shell(fb): break if line: - args = line.split() + args = shlex.split(line) cmd = args.pop(0) if cmd in fb.commands: fb.dispatch(fb.commands[cmd], args, {}); -- cgit v1.3.1