- Working completion
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@234 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
9a51c38be6
commit
55328d6b06
@ -47,26 +47,30 @@ class SimpleCompleter(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def complete(self, text, state):
|
def complete(self, text, state):
|
||||||
#print test, state
|
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
if state == 0:
|
if state == 0:
|
||||||
# This is the first time for this text, so build a match list.
|
# This is the first time for this text, so build a match list.
|
||||||
if text:
|
if text:
|
||||||
self.matches = [s
|
|
||||||
|
self.matches =[s
|
||||||
for s in self.options
|
for s in self.options
|
||||||
if s and s.startswith(text)]
|
if s and s.startswith(text)]
|
||||||
|
|
||||||
#Add the completion for files here
|
#Add the completion for files here
|
||||||
try:
|
try:
|
||||||
listf=os.listdir(os.path.dirname(text))
|
d=os.path.dirname(text)
|
||||||
|
listf=os.listdir(d)
|
||||||
|
|
||||||
|
d+="/"
|
||||||
except:
|
except:
|
||||||
|
d=""
|
||||||
listf=os.listdir('.')
|
listf=os.listdir('.')
|
||||||
|
|
||||||
for i in listf:
|
for i in listf:
|
||||||
|
i=(d+i).replace('//','/')
|
||||||
if i.startswith(text):
|
if i.startswith(text):
|
||||||
if os.path.isdir(i):
|
if os.path.isdir(i):
|
||||||
i+="/"
|
i=i+"/"
|
||||||
self.matches.append(i)
|
self.matches.append(i)
|
||||||
|
|
||||||
logging.debug('%s matches: %s', repr(text), self.matches)
|
logging.debug('%s matches: %s', repr(text), self.matches)
|
||||||
@ -88,7 +92,6 @@ class SimpleCompleter(object):
|
|||||||
relations={}
|
relations={}
|
||||||
completer=SimpleCompleter(['LIST','LOAD ','UNLOAD ','HELP ','QUIT','SAVE ','_PRODUCT ','_UNION ','_INTERSECTION ','_DIFFERENCE ','_JOIN ','_LJOIN ','_RJOIN ','_FJOIN ','_PROJECTION ','_RENAME_TO ','_SELECTION ','_RENAME '])
|
completer=SimpleCompleter(['LIST','LOAD ','UNLOAD ','HELP ','QUIT','SAVE ','_PRODUCT ','_UNION ','_INTERSECTION ','_DIFFERENCE ','_JOIN ','_LJOIN ','_RJOIN ','_FJOIN ','_PROJECTION ','_RENAME_TO ','_SELECTION ','_RENAME '])
|
||||||
|
|
||||||
|
|
||||||
def load_relation(filename,defname=None):
|
def load_relation(filename,defname=None):
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print >> sys.stderr, "%s is not a file" % filename
|
print >> sys.stderr, "%s is not a file" % filename
|
||||||
@ -239,6 +242,8 @@ def main(files=[]):
|
|||||||
|
|
||||||
readline.parse_and_bind('tab: complete')
|
readline.parse_and_bind('tab: complete')
|
||||||
readline.parse_and_bind('set editing-mode emacs')
|
readline.parse_and_bind('set editing-mode emacs')
|
||||||
|
readline.set_completer_delims(" ")
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user