Better code style

master
Salvo 'LtWorf' Tomaselli 2016-01-03 19:43:38 +07:00
parent 5563e1cafd
commit ce348149f1
2 changed files with 8 additions and 7 deletions

@ -70,13 +70,13 @@ def optimize_all(expression, rels, specific=True, general=True, debug=None):
for i in optimizations.specific_optimizations:
res = i(n, rels) # Performs the optimization
if res != 0 and dbg:
debug.append(n.__str__())
debug.append(str(n))
total += res
if general:
for i in optimizations.general_optimizations:
res = i(n) # Performs the optimization
if res != 0 and dbg:
debug.append(n.__str__())
debug.append(str(n))
total += res
return n.__str__()

@ -154,7 +154,9 @@ class relForm(QtWidgets.QMainWindow):
res_rel,query = self.user_interface.split_query(self.ui.txtQuery.text(),None)
try:
result = optimizer.optimize_all(
query, self.user_interface.relations)
query,
self.user_interface.relations
)
if res_rel:
result = '%s = %s' % (res_rel, result)
self.ui.txtQuery.setText(result)
@ -217,15 +219,14 @@ class relForm(QtWidgets.QMainWindow):
# Set content
for i in rel.content:
item = QtWidgets.QTreeWidgetItem()
for j in range(len(i)):
item.setText(j, i[j])
for j,k in enumerate(i):
item.setText(j, k)
self.ui.table.addTopLevelItem(item)
# Sets columns
for i, attr in enumerate(rel.header):
self.ui.table.headerItem().setText(i, attr)
self.ui.table.resizeColumnToContents(
i) # Must be done in order to avoid too small columns
self.ui.table.resizeColumnToContents(i)
def printRelation(self, item):
self.selectedRelation = self.user_interface.relations[item.text()]