Can load relations specified in command line
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@210 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
6734fc66e5
commit
6f8ad973b9
@ -91,4 +91,5 @@
|
||||
|
||||
0.11
|
||||
- Font is set only on windows (Rev 206)
|
||||
- Improved futile_union_intersection_subtraction in case of A-A, when A is a sub-query (Rev 208)
|
||||
- Improved futile_union_intersection_subtraction in case of A-A, when A is a sub-query (Rev 208)
|
||||
- Can load relations specified in command line (Rev 209)
|
@ -4,6 +4,8 @@ relational \(em Python implementation of Relational algebra.
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fBrelational\fR [\-v\fR\fP]
|
||||
.br
|
||||
\fBrelational\fR [ FILE .\|.\|.]
|
||||
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
|
@ -48,6 +48,16 @@ if __name__ == "__main__":
|
||||
|
||||
ui = maingui.Ui_Form()
|
||||
ui.setupUi(Form)
|
||||
|
||||
for i in range(1,len(sys.argv)):
|
||||
f=sys.argv[i].split('/')
|
||||
defname=f[len(f)-1].lower()
|
||||
if (defname.endswith(".csv") or defname.endswith(".tlb")): #removes the extension
|
||||
defname=defname[:-4]
|
||||
print 'Loading file "%s" with name "%s"' % (sys.argv[i],defname)
|
||||
ui.loadRelation(sys.argv[i],defname)
|
||||
|
||||
|
||||
Form.show()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
@ -157,13 +157,21 @@ class Ui_Form(object):
|
||||
ui.setupUi(self.About)
|
||||
self.About.show()
|
||||
|
||||
def loadRelation(self):
|
||||
def loadRelation(self,filename=None,name=None):
|
||||
'''Loads a relation. Without parameters it will ask the user which relation to load,
|
||||
otherwise it will load filename, giving it name'''
|
||||
#Asking for file to load
|
||||
filename = QtGui.QFileDialog.getOpenFileName(None,QtGui.QApplication.translate("Form", "Load Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.csv);;Old Relations (*.tlb);;Text Files (*.txt);;All Files (*)"))
|
||||
if filename==None:
|
||||
filename = QtGui.QFileDialog.getOpenFileName(None,QtGui.QApplication.translate("Form", "Load Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.csv);;Old Relations (*.tlb);;Text Files (*.txt);;All Files (*)"))
|
||||
|
||||
#Default relation's name
|
||||
f=str(filename.toUtf8()).split('/') #Split the full path
|
||||
defname=f[len(f)-1].lower() #Takes only the lowercase filename
|
||||
|
||||
else:
|
||||
f=filename.split('/') #Split the full path
|
||||
defname=f[len(f)-1].lower() #Takes only the lowercase filename
|
||||
|
||||
#Default relation's name
|
||||
f=str(filename.toUtf8()).split('/') #Split the full path
|
||||
defname=f[len(f)-1].lower() #Takes only the lowercase filename
|
||||
if len(defname)==0:
|
||||
return
|
||||
use_csv=True
|
||||
@ -172,16 +180,18 @@ class Ui_Form(object):
|
||||
defname=defname[:-4]
|
||||
use_csv=False #Old format, not using csv
|
||||
|
||||
|
||||
if (defname.endswith(".csv")): #removes the extension
|
||||
defname=defname[:-4]
|
||||
|
||||
res=QtGui.QInputDialog.getText(self.Form, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the name for the new relation"),
|
||||
QtGui.QLineEdit.Normal,defname)
|
||||
if res[1]==False:
|
||||
return
|
||||
|
||||
self.relations[str(res[0].toUtf8())]=relation.relation(filename,use_csv)
|
||||
if name==None:
|
||||
res=QtGui.QInputDialog.getText(self.Form, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the name for the new relation"),
|
||||
QtGui.QLineEdit.Normal,defname)
|
||||
if res[1]==False or len(res[0])==0:
|
||||
return
|
||||
self.relations[str(res[0].toUtf8())]=relation.relation(filename,use_csv)
|
||||
else:
|
||||
self.relations[name]=relation.relation(filename,use_csv)
|
||||
|
||||
self.updateRelations()
|
||||
def insertTuple(self):
|
||||
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
|
||||
|
Loading…
Reference in New Issue
Block a user