diff options
| author | alex.boterolowry <alex.boterolowry@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2> | 2009-11-13 23:36:40 +0000 |
|---|---|---|
| committer | alex.boterolowry <alex.boterolowry@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2> | 2009-11-13 23:36:40 +0000 |
| commit | 54363e9636394464bbdaa54934f333b5239ed9bc (patch) | |
| tree | bcb0944c40b902bfd59ec9e5d34db944d9aabaea /freebase | |
| parent | ff2404d1f0858b5ac281a7d7a5f7d15e4bcc9940 (diff) | |
use shlex.split instead of string.split
git-svn-id: http://freebase-python.googlecode.com/svn/trunk@229 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2
Diffstat (limited to 'freebase')
| -rwxr-xr-x | freebase/fcl/commands.py | 28 |
1 files 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, {}); |
