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
@ -92,3 +92,4 @@
|
|||||||
0.11
|
0.11
|
||||||
- Font is set only on windows (Rev 206)
|
- 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"
|
.SH "SYNOPSIS"
|
||||||
.PP
|
.PP
|
||||||
\fBrelational\fR [\-v\fR\fP]
|
\fBrelational\fR [\-v\fR\fP]
|
||||||
|
.br
|
||||||
|
\fBrelational\fR [ FILE .\|.\|.]
|
||||||
|
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
.PP
|
.PP
|
||||||
|
@ -48,6 +48,16 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
ui = maingui.Ui_Form()
|
ui = maingui.Ui_Form()
|
||||||
ui.setupUi(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()
|
Form.show()
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
@ -157,13 +157,21 @@ class Ui_Form(object):
|
|||||||
ui.setupUi(self.About)
|
ui.setupUi(self.About)
|
||||||
self.About.show()
|
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
|
#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:
|
if len(defname)==0:
|
||||||
return
|
return
|
||||||
use_csv=True
|
use_csv=True
|
||||||
@ -172,16 +180,18 @@ class Ui_Form(object):
|
|||||||
defname=defname[:-4]
|
defname=defname[:-4]
|
||||||
use_csv=False #Old format, not using csv
|
use_csv=False #Old format, not using csv
|
||||||
|
|
||||||
|
|
||||||
if (defname.endswith(".csv")): #removes the extension
|
if (defname.endswith(".csv")): #removes the extension
|
||||||
defname=defname[:-4]
|
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"),
|
if name==None:
|
||||||
QtGui.QLineEdit.Normal,defname)
|
res=QtGui.QInputDialog.getText(self.Form, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the name for the new relation"),
|
||||||
if res[1]==False:
|
QtGui.QLineEdit.Normal,defname)
|
||||||
return
|
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.relations[str(res[0].toUtf8())]=relation.relation(filename,use_csv)
|
|
||||||
self.updateRelations()
|
self.updateRelations()
|
||||||
def insertTuple(self):
|
def insertTuple(self):
|
||||||
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
|
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user