Merge pull request #38 from ltworf/win_patches

Pick some fixes from the windows branch
master
Salvo 'LtWorf' Tomaselli 2020-08-30 19:47:52 +07:00 committed by GitHub
commit bf4a113f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

@ -82,8 +82,6 @@ if __name__ == "__main__":
if x11:
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
import sip # needed on windows
from PyQt5 import QtWidgets
try:
from relational_gui import guihandler, about, surveyForm

@ -39,7 +39,8 @@ def optimize_program(code: str, rels: Dict[str, Relation]) -> str:
lines = code.split('\n')
context: Dict[str, Node] = {}
for line in lines:
last_res = None
for line in lines:
# skip comments or empty lines
line = line.strip()
if line.startswith(';') or not line:
@ -51,6 +52,9 @@ def optimize_program(code: str, rels: Dict[str, Relation]) -> str:
parsed = tree(query)
_replace_leaves(parsed, context)
context[res] = parsed
if last_res is None:
return ''
node = optimize_all(context[last_res], rels, tostr=False)
return querysplit.split(node, rels)

@ -113,7 +113,7 @@ class Relation:
format as defined in RFC4180.
'''
import csv
with open(filename, 'w') as fp:
with open(filename, 'w', newline='\n') as fp:
writer = csv.writer(fp) # Creating csv writer
# It wants an iterable containing iterables
@ -193,7 +193,7 @@ class Relation:
if eval(c_expr, attributes):
content.append(i)
except Exception as e:
raise Exception(f'Failed to evaluate {expr} with {attributes}\n{e}')
raise Exception(f'Failed to evaluate {expr} with {i}\n{e}')
return Relation(self.header, frozenset(content))
def product(self, other: 'Relation') -> 'Relation':