From f4d47a01e91c3946fd20f9f650013b76abf9c9bb Mon Sep 17 00:00:00 2001 From: LtWorf Date: Mon, 21 Jun 2010 21:02:47 +0000 Subject: [PATCH] - Upgraded manpage - Can save relations - Better -v printout - Added comments git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@236 014f5005-505e-4b48-8d0a-63407b615a7c --- relational.1 | 16 +++++++++++----- relational_gui.py | 14 ++++++++++---- relational_readline/linegui.py | 24 +++++++++++++++++++++--- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/relational.1 b/relational.1 index 2f4c4f2..b10c69e 100644 --- a/relational.1 +++ b/relational.1 @@ -3,13 +3,11 @@ relational \(em Python implementation of Relational algebra. .SH "SYNOPSIS" .PP -\fBrelational\fR [\-v\fR\fP] -.br -\fBrelational\fR [ FILE .\|.\|.] +\fBrelational\fR [OPTIONS\fR\fP] [ FILE .\|.\|.] .SH "DESCRIPTION" .PP -Python implementation of Relational algebra. This program provides a GUI to execute relational algebra queries. It is meant to be used for educational purposes. +Python implementation of Relational algebra. This program provides an UI to execute relational algebra queries. It is meant to be used for educational purposes. .SH "OPTIONS" .PP @@ -19,6 +17,15 @@ options is included below. However, the ordering is very strict \- .IP "\fB-v\fP Show version information. +.IP "\fB-h\fP +Shows help. + +.IP "\fB-q\fP +Using the Qt4 GUI (default). + +.IP "\fB-r\fP +Uses the readline UI. + .SH "AUTHOR" .PP This manual page was written by Salvo 'LtWorf' Tomaselli for @@ -26,4 +33,3 @@ the \fBDebian GNU/Linux\fP system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License version 3 or any later version published by the Free Software Foundation. -.\" created by instant / docbook-to-man, Fri 10 Oct 2008, 19:02 diff --git a/relational_gui.py b/relational_gui.py index 1435f5d..79ee13d 100755 --- a/relational_gui.py +++ b/relational_gui.py @@ -27,15 +27,20 @@ from relational import relation, parser version="0.11" -def printver(): - print "Relational" +def printver(exit=True): + print "Relational %s" % version + print "Copyright (C) 2008 Salvo 'LtWorf' Tomaselli." + print print "This program comes with ABSOLUTELY NO WARRANTY." print "This is free software, and you are welcome to redistribute it" print "under certain conditions." print "For details see the GPLv3 Licese." print - print "Version: %s"%version - sys.exit(0) + print "Written by Salvo 'LtWorf' Tomaselli " + print + print "http://galileo.dmi.unict.it/wiki/relational/doku.php" + if exit: + sys.exit(0) def printhelp(code=0): print "Relational" @@ -105,6 +110,7 @@ if __name__ == "__main__": Form.show() sys.exit(app.exec_()) else: + printver(False) import relational_readline.linegui relational_readline.linegui.main(files) diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index 73e62ca..20ba0fe 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -178,9 +178,25 @@ def exec_line(command): else: print "No such relation %s" % pars[1] pass - #elif command=='SAVE': //TODO + elif command.startswith('SAVE'): + pars=command.split(' ') + if len(pars)!=3: + print "Missing parameter" + return + + filename=pars[1] + defname=pars[2] + + if defname not in relations: + print "No such relation %s" % defname + return + + try: + relations[defname].save(filename) + except Exception,e: + print e else: - exec_query( command) + exec_query(command) def replacements(query): '''This funcion replaces ascii easy operators with the correct ones''' @@ -247,6 +263,8 @@ def exec_query(command): print e def main(files=[]): + print "> ; Type HELP to get the HELP" + print "> ; Completion is activated using the tab" for i in files: load_relation(i) @@ -261,7 +279,7 @@ def main(files=[]): while True: try: line = raw_input('> ') - if isinstance(line,str) and len(line)>0: + if isinstance(line,str) and len(line)>0 and not line.startswith(';'): exec_line(line) except EOFError: print