Style
This commit is contained in:
parent
98ac364dc7
commit
73dd14d9dd
@ -151,6 +151,3 @@ class user_interface (object):
|
||||
str(e)
|
||||
))
|
||||
return r
|
||||
|
||||
|
||||
|
||||
|
@ -77,7 +77,9 @@ class TokenizerException (Exception):
|
||||
class ParserException (Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CallableString(str):
|
||||
|
||||
'''
|
||||
This is a string. However it is also callable.
|
||||
|
||||
@ -96,6 +98,7 @@ class CallableString(str):
|
||||
'''
|
||||
return eval(self, context)
|
||||
|
||||
|
||||
class node (object):
|
||||
|
||||
'''This class is a node of a relational expression. Leaves are relations
|
||||
@ -327,7 +330,8 @@ def tokenize(expression):
|
||||
# unary operator: this status is more complex, since it will be followed by a parameter AND a
|
||||
# sub-expression.
|
||||
# sub-expression: this status is entered when finding a '(' and will be exited when finding a ')'.
|
||||
# means that the others open must be counted to determine which close is the right one.'''
|
||||
# means that the others open must be counted to determine which close is
|
||||
# the right one.
|
||||
|
||||
expression = expression.strip() # Removes initial and endind spaces
|
||||
state = 0
|
||||
|
@ -111,7 +111,9 @@ class relation (object):
|
||||
newt.header = header(self.header)
|
||||
for i in self.content:
|
||||
# Fills the attributes dictionary with the values of the tuple
|
||||
attributes = {attr:i[j].autocast() for j, attr in enumerate(self.header)}
|
||||
attributes = {attr: i[j].autocast()
|
||||
for j, attr in enumerate(self.header)
|
||||
}
|
||||
|
||||
try:
|
||||
if eval(expr, attributes):
|
||||
@ -129,7 +131,8 @@ class relation (object):
|
||||
|
||||
if (self.__class__ != other.__class__)or(self.header.sharedAttributes(other.header) != 0):
|
||||
raise Exception(
|
||||
'Unable to perform product on relations with colliding attributes')
|
||||
'Unable to perform product on relations with colliding attributes'
|
||||
)
|
||||
newt = relation()
|
||||
newt.header = header(self.header + other.header)
|
||||
|
||||
@ -398,8 +401,7 @@ class relation (object):
|
||||
affected = 0
|
||||
attributes = {}
|
||||
keys = dic.keys() # List of headers to modify
|
||||
f_ids = self.header.getAttributesId(
|
||||
keys) # List of indexes corresponding to keys
|
||||
f_ids = self.header.getAttributesId(keys)
|
||||
|
||||
# new_content=[] #New content of the relation
|
||||
for i in self.content:
|
||||
|
@ -25,9 +25,11 @@ import re
|
||||
|
||||
RELATION_NAME_REGEXP = r'^[_a-zA-Z]+[_a-zA-Z0-9]*$'
|
||||
|
||||
|
||||
class rstring (str):
|
||||
|
||||
'''String subclass with some custom methods'''
|
||||
|
||||
def autocast(self):
|
||||
'''
|
||||
Returns the automatic cast for this
|
||||
|
@ -87,7 +87,10 @@ if __name__ == "__main__":
|
||||
try:
|
||||
from relational_gui import maingui, guihandler, about, surveyForm
|
||||
except:
|
||||
print ("Module relational_gui is missing.\nPlease install relational package.",file=sys.stderr)
|
||||
print (
|
||||
"Module relational_gui is missing.\nPlease install relational package.",
|
||||
file=sys.stderr
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
about.version = version
|
||||
@ -103,7 +106,7 @@ if __name__ == "__main__":
|
||||
form = guihandler.relForm(ui)
|
||||
ui.setupUi(form)
|
||||
f = QtGui.QFont()
|
||||
size = f.pointSize();
|
||||
size = f.pointSize()
|
||||
if sys.platform.startswith('win'):
|
||||
winFont = 'Cambria'
|
||||
symbolFont = 'Segoe UI Symbol'
|
||||
@ -123,7 +126,9 @@ if __name__ == "__main__":
|
||||
form.restore_settings()
|
||||
|
||||
m = enumerate(map(os.path.isfile, files))
|
||||
invalid = ' '.join((files[i[0]] for i in (filter(lambda x: not x[1], m))))
|
||||
invalid = ' '.join(
|
||||
(files[i[0]] for i in (filter(lambda x: not x[1], m)))
|
||||
)
|
||||
if invalid:
|
||||
print ("%s: not a file" % invalid, file=sys.stderr)
|
||||
printhelp(12)
|
||||
@ -137,7 +142,10 @@ if __name__ == "__main__":
|
||||
try:
|
||||
import relational_readline.linegui
|
||||
except:
|
||||
print ("Module relational_readline is missing.\nPlease install relational-cli package.",file=sys.stderr)
|
||||
print (
|
||||
"Module relational_readline is missing.\nPlease install relational-cli package.",
|
||||
file=sys.stderr
|
||||
)
|
||||
sys.exit(3)
|
||||
relational_readline.linegui.version = version
|
||||
relational_readline.linegui.main(files)
|
||||
|
@ -80,7 +80,8 @@ class creatorForm(QtWidgets.QDialog):
|
||||
self.table.setItem(1, 1, i11)
|
||||
|
||||
def create_relation(self):
|
||||
h = (self.table.item(0, i).text() for i in range(self.table.columnCount()))
|
||||
h = (self.table.item(0, i).text()
|
||||
for i in range(self.table.columnCount()))
|
||||
|
||||
try:
|
||||
header = relation.header(h)
|
||||
|
@ -79,7 +79,8 @@ class relForm(QtWidgets.QMainWindow):
|
||||
|
||||
query = self.ui.txtQuery.text()
|
||||
try:
|
||||
result = optimizer.optimize_all(query, self.user_interface.relations)
|
||||
result = optimizer.optimize_all(
|
||||
query, self.user_interface.relations)
|
||||
self.ui.txtQuery.setText(result)
|
||||
except Exception as e:
|
||||
self.error(e)
|
||||
@ -222,7 +223,8 @@ class relForm(QtWidgets.QMainWindow):
|
||||
name = res[0]
|
||||
if not rtypes.is_valid_relation_name(name):
|
||||
r = QtWidgets.QApplication.translate(
|
||||
"Form", str("Wrong name for destination relation: %s." % name)
|
||||
"Form", str(
|
||||
"Wrong name for destination relation: %s." % name)
|
||||
)
|
||||
QtWidgets.QMessageBox.information(
|
||||
self, QtWidgets.QApplication.translate("Form", "Error"), r
|
||||
@ -257,7 +259,8 @@ class relForm(QtWidgets.QMainWindow):
|
||||
def restore_settings(self):
|
||||
# self.settings.value('session_name','default').toString()
|
||||
self.setMultiline(self.settings.value('multiline', 'false') == 'true')
|
||||
self.ui.txtMultiQuery.setPlainText(self.settings.value('multiline/query',''))
|
||||
self.ui.txtMultiQuery.setPlainText(
|
||||
self.settings.value('multiline/query', ''))
|
||||
try:
|
||||
self.restoreGeometry(self.settings.value('maingui/geometry'))
|
||||
self.restoreState(self.settings.value('maingui/windowState'))
|
||||
|
@ -24,7 +24,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
from relational import maintenance
|
||||
|
||||
|
||||
|
||||
class surveyForm (QtWidgets.QWidget):
|
||||
|
||||
'''This class is the form used for the survey, needed to intercept the events.
|
||||
|
Loading…
x
Reference in New Issue
Block a user