From 261bd4469f851b3aba860611febd3e5ae2fd730e Mon Sep 17 00:00:00 2001 From: LtWorf Date: Mon, 21 Jun 2010 14:30:27 +0000 Subject: [PATCH] - Can be used from the main module git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@232 014f5005-505e-4b48-8d0a-63407b615a7c --- relational_gui.py | 11 +++++++---- relational_readline/__init__.py | 0 relational_readline/linegui.py | 17 ++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 relational_readline/__init__.py diff --git a/relational_gui.py b/relational_gui.py index e38a976..a172426 100755 --- a/relational_gui.py +++ b/relational_gui.py @@ -45,7 +45,8 @@ def printhelp(code=0): print " -v Print version and exits" print " -h Print this help and exits" print " -q Uses QT user interface (default)" - print " -c Uses curses user interface" + #print " -c Uses curses user interface" + print " -r Uses readline user interface" sys.exit(code) if __name__ == "__main__": @@ -61,7 +62,7 @@ if __name__ == "__main__": #Getting command line try: - switches,files=getopt.getopt(sys.argv[1:],"vhqc") + switches,files=getopt.getopt(sys.argv[1:],"vhqr") except: printhelp(1) @@ -72,7 +73,7 @@ if __name__ == "__main__": printhelp() elif i[0]=='-q': x11=True - elif i[0]=='-c': + elif i[0]=='-r': x11=False if x11: @@ -103,5 +104,7 @@ if __name__ == "__main__": Form.show() sys.exit(app.exec_()) - else: #TODO load with curses interface + else: #TODO load with readline interface + import relational_readline.linegui + relational_readline.linegui.main(files) pass diff --git a/relational_readline/__init__.py b/relational_readline/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index cb66867..9835fbc 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -86,6 +86,9 @@ def load_relation(filename,defname=None): try: relations[defname]=relation.relation(filename) + + completer.add_completion(defname) + print "Loaded relation %s"% defname return defname except Exception, e: print e @@ -109,11 +112,7 @@ def exec_line(command): defname=pars[2] else: defname=None - defname=load_relation(filename,defname) - if defname==None: return - - completer.add_completion(defname) - print "Loaded relation %s"% defname + load_relation(filename,defname) elif command=='UNLOAD ': #//TODO @@ -186,6 +185,10 @@ def exec_query(command): print e def main(files=[]): + + for i in files: + load_relation(i) + readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') @@ -201,5 +204,5 @@ def main(files=[]): - -main() \ No newline at end of file +if __name__ == "__main__": + main() \ No newline at end of file