This commit is contained in:
Salvo 'LtWorf' Tomaselli 2016-01-03 09:28:45 +01:00
parent 474bea6ff5
commit 0dd2ef2f1d
6 changed files with 36 additions and 19 deletions

View File

@ -508,6 +508,7 @@ def select_union_intersect_subtract(n):
return changes + recoursive_scan(select_union_intersect_subtract, n)
def union_and_product(n):
'''
A * B A * C = A * (B C)

View File

@ -343,7 +343,8 @@ def tokenize(expression):
else: # Relation (hopefully)
expression += ' ' # To avoid the special case of the ending
#Initial part is a relation, stop when the name of the relation is over
# Initial part is a relation, stop when the name of the relation is
# over
for r in range(1, len(expression)):
if rtypes.RELATION_NAME_REGEXP.match(expression[:r + 1]) is None:
break

View File

@ -64,6 +64,7 @@ class Relation (object):
self.header = Header(next(reader)) # read 1st line
iterator = ((self.insert(i) for i in reader))
deque(iterator, maxlen=0)
def _make_duplicate(self, copy):
'''Flag that the relation "copy" is pointing
to the same set as this relation.'''
@ -426,7 +427,9 @@ class Relation (object):
affected = self.selection(expr)
not_affected = self.difference(affected)
new_values = tuple(zip(self.header.getAttributesId(dic.keys()), dic.values()))
new_values = tuple(
zip(self.header.getAttributesId(dic.keys()), dic.values())
)
for i in set(affected.content):
i = list(i)

View File

@ -32,7 +32,9 @@ class Rstring (str):
int_regexp = re.compile(r'^[\+\-]{0,1}[0-9]+$')
float_regexp = re.compile(r'^[\+\-]{0,1}[0-9]+(\.([0-9])+)?$')
date_regexp = re.compile(r'^([0-9]{1,4})(\\|-|/)([0-9]{1,2})(\\|-|/)([0-9]{1,2})$')
date_regexp = re.compile(
r'^([0-9]{1,4})(\\|-|/)([0-9]{1,2})(\\|-|/)([0-9]{1,2})$'
)
def autocast(self):
'''
@ -155,6 +157,7 @@ class Rdate (object):
def __sub__(self, other):
return (self.intdate - other.intdate).days
def is_valid_relation_name(name):
'''Checks if a name is valid for a relation.
Returns boolean'''

View File

@ -106,7 +106,6 @@ class relForm(QtWidgets.QMainWindow):
action.setShortcutContext(0)
widget.addAction(action)
def checkVersion(self):
from relational import maintenance
online = maintenance.check_latest_version()
@ -250,8 +249,11 @@ class relForm(QtWidgets.QMainWindow):
self, QtWidgets.QApplication.translate("Form", "Error"), r
)
return
filename = QtWidgets.QFileDialog.getSaveFileName(self, QtWidgets.QApplication.translate(
"Form", "Save Relation"), "", QtWidgets.QApplication.translate("Form", "Relations (*.csv)"))[0]
filename = QtWidgets.QFileDialog.getSaveFileName(
self, QtWidgets.QApplication.translate("Form", "Save Relation"),
"",
QtWidgets.QApplication.translate("Form", "Relations (*.csv)")
)[0]
if (len(filename) == 0): # Returns if no file was selected
return
self.selectedRelation.save(filename)
@ -366,8 +368,15 @@ class relForm(QtWidgets.QMainWindow):
It shouldn't be called giving filename but not giving name.'''
# Asking for file to load
if not filenames:
f = QtWidgets.QFileDialog.getOpenFileNames(self, QtWidgets.QApplication.translate(
"Form", "Load Relation"), "", QtWidgets.QApplication.translate("Form", "Relations (*.csv);;Text Files (*.txt);;All Files (*)"))
f = QtWidgets.QFileDialog.getOpenFileNames(
self,
QtWidgets.QApplication.translate("Form", "Load Relation"),
"",
QtWidgets.QApplication.translate(
"Form",
"Relations (*.csv);;Text Files (*.txt);;All Files (*)"
)
)
filenames = f[0]
for f in filenames: