- More detail for errors in evaluation
- Printing errors on stdout too, as well as query conversion to python git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@225 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
425dc5cf4c
commit
ad84f402d5
@ -115,9 +115,11 @@ class relation (object):
|
|||||||
else:
|
else:
|
||||||
attributes[self.header.attributes[j]]=i[j]
|
attributes[self.header.attributes[j]]=i[j]
|
||||||
|
|
||||||
|
try:
|
||||||
if eval(expr,attributes):
|
if eval(expr,attributes):
|
||||||
newt.content.append(i)
|
newt.content.append(i)
|
||||||
|
except Exception,e:
|
||||||
|
raise Exception("Failed to evaluate %s\n%s" % (expr,e.__str__()))
|
||||||
return newt
|
return newt
|
||||||
def product (self,other):
|
def product (self,other):
|
||||||
'''Cartesian product, attributes must be different to avoid collisions
|
'''Cartesian product, attributes must be different to avoid collisions
|
||||||
|
@ -89,68 +89,79 @@ def main():
|
|||||||
curses.flash()
|
curses.flash()
|
||||||
curses.textpad.rectangle(win,0,0,5,10)'''
|
curses.textpad.rectangle(win,0,0,5,10)'''
|
||||||
|
|
||||||
|
squery=''
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
c = win.window().getch()
|
c = win.window().getch()
|
||||||
s=""
|
|
||||||
if c==27: #Escape
|
if c==27: #Escape
|
||||||
query.window().addstr(add_symbol(symselect))
|
squery+=add_symbol(symselect)
|
||||||
query.window().refresh()
|
|
||||||
else:
|
|
||||||
#w.window().addstr(str(c))
|
|
||||||
query.window().addstr(str(chr(c)))
|
|
||||||
|
|
||||||
|
|
||||||
def init_symbol_list(termsize):
|
#elif c==curses.KEY_BACKSPACE: #Delete
|
||||||
|
elif c==13:
|
||||||
|
squery=squery[:-1]
|
||||||
|
else:
|
||||||
|
squery+=chr(c);
|
||||||
|
|
||||||
|
|
||||||
|
query.window().box()
|
||||||
|
query.top()
|
||||||
|
query.window().addstr(1,1,spaces(termsize[1]-2))
|
||||||
|
query.window().addstr(1,1,squery)
|
||||||
|
|
||||||
|
query.window().refresh()
|
||||||
|
def init_symbol_list(termsize,create=True):
|
||||||
|
|
||||||
p=curses.panel.new_panel(curses.newwin(15,16,1,0))
|
if create:
|
||||||
|
p=curses.panel.new_panel(curses.newwin(15,16,2,termsize[1]/2-7))
|
||||||
|
else:
|
||||||
|
p=termsize
|
||||||
p.window().box()
|
p.window().box()
|
||||||
#p.window().addstr(1,1,"\n8 \na \nb \n")
|
#p.window().addstr(1,1,"\n8 \na \nb \n")
|
||||||
p.window().addstr(01,2,"0 *")
|
p.window().addstr(01,2,"0 *")
|
||||||
p.window().addstr(02,2,"1 -")
|
p.window().addstr(02,2,"1 -")
|
||||||
p.window().addstr(03,2,"2 ᑌ")
|
p.window().addstr(03,2,"2 ᑌ")
|
||||||
p.window().addstr(04,2,"3 ᑎ")
|
p.window().addstr(04,2,"3 ᑎ")
|
||||||
p.window().addstr(05,2,"4 ᐅᐊ")
|
p.window().addstr(05,2,"4 ᐅᐊ")
|
||||||
p.window().addstr(06,2,"5 ᐅLEFTᐊ")
|
p.window().addstr(06,2,"5 ᐅLEFTᐊ")
|
||||||
p.window().addstr(07,2,"6 ᐅRIGHTᐊ")
|
p.window().addstr(07,2,"6 ᐅRIGHTᐊ")
|
||||||
p.window().addstr( 8,2,"7 ᐅFULLᐊ")
|
p.window().addstr( 8,2,"7 ᐅFULLᐊ")
|
||||||
p.window().addstr( 9,2,"8 σ")
|
p.window().addstr( 9,2,"8 σ")
|
||||||
p.window().addstr(10,2,"9 ρ")
|
p.window().addstr(10,2,"9 ρ")
|
||||||
p.window().addstr(11,2,"a π")
|
p.window().addstr(11,2,"a π")
|
||||||
p.window().addstr(12,2,"b ➡")
|
p.window().addstr(12,2,"b ➡")
|
||||||
p.window().addstr(13,2,"")
|
p.window().addstr(13,2,"")
|
||||||
|
|
||||||
|
#p.hide()
|
||||||
|
|
||||||
|
|
||||||
p.hide()
|
|
||||||
return p
|
return p
|
||||||
pass
|
|
||||||
def add_symbol(p):
|
def add_symbol(p):
|
||||||
d_={'0':'*',
|
'''Shows the panel to add a symbol
|
||||||
'1':'-',
|
and then returns the choosen symbol itself'''
|
||||||
'2':'ᑌ',
|
init_symbol_list(p,False)
|
||||||
'3':'ᑎ',
|
|
||||||
'4':'ᐅᐊ',
|
d_={'0':'*','1':'-','2':'ᑌ','3':'ᑎ','4':'ᐅᐊ','5':'ᐅLEFTᐊ','6':'ᐅRIGHTᐊ','7':'ᐅFULLᐊ','8':'σ','9':'ρ','a':'π','b':'➡'}
|
||||||
'5':'ᐅLEFTᐊ',
|
|
||||||
'6':'ᐅRIGHTᐊ',
|
|
||||||
'7':'ᐅFULLᐊ',
|
|
||||||
'8':'σ',
|
|
||||||
'9':'ρ',
|
|
||||||
'a':'π',
|
|
||||||
'b':'➡'}
|
|
||||||
|
|
||||||
|
|
||||||
p.show()
|
p.show()
|
||||||
|
p.top()
|
||||||
p.window().refresh()
|
p.window().refresh()
|
||||||
#curses.napms(1000)
|
|
||||||
c = p.window().getch()
|
c = p.window().getch()
|
||||||
|
|
||||||
p.hide()
|
p.hide()
|
||||||
p.window().refresh()
|
p.window().refresh()
|
||||||
return d_[chr(c)]
|
try:
|
||||||
main()
|
char=d_[chr(c)]
|
||||||
|
except:
|
||||||
|
char=''
|
||||||
|
return char
|
||||||
|
|
||||||
|
def spaces(t):
|
||||||
|
'''Returns a number of spaces specified t'''
|
||||||
|
s=''
|
||||||
terminate()
|
for i in range(t):
|
||||||
|
s+=' '
|
||||||
|
return s
|
||||||
|
if __name__=='__main__':
|
||||||
|
main()
|
||||||
|
terminate()
|
@ -85,6 +85,7 @@ class Ui_Form(object):
|
|||||||
self.selectedRelation=result
|
self.selectedRelation=result
|
||||||
self.showRelation(self.selectedRelation) #Show the result in the table
|
self.showRelation(self.selectedRelation) #Show the result in the table
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
print e
|
||||||
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.message) )
|
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.message) )
|
||||||
def showRelation(self,rel):
|
def showRelation(self,rel):
|
||||||
'''Shows the selected relation into the table'''
|
'''Shows the selected relation into the table'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user