Merge pull request #38 from ltworf/win_patches
Pick some fixes from the windows branch
This commit is contained in:
commit
bf4a113f0c
@ -82,8 +82,6 @@ if __name__ == "__main__":
|
|||||||
if x11:
|
if x11:
|
||||||
import signal
|
import signal
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
||||||
import sip # needed on windows
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
try:
|
try:
|
||||||
from relational_gui import guihandler, about, surveyForm
|
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')
|
lines = code.split('\n')
|
||||||
context: Dict[str, Node] = {}
|
context: Dict[str, Node] = {}
|
||||||
|
|
||||||
for line in lines:
|
last_res = None
|
||||||
|
for line in lines:
|
||||||
# skip comments or empty lines
|
# skip comments or empty lines
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line.startswith(';') or not line:
|
if line.startswith(';') or not line:
|
||||||
@ -51,6 +52,9 @@ def optimize_program(code: str, rels: Dict[str, Relation]) -> str:
|
|||||||
parsed = tree(query)
|
parsed = tree(query)
|
||||||
_replace_leaves(parsed, context)
|
_replace_leaves(parsed, context)
|
||||||
context[res] = parsed
|
context[res] = parsed
|
||||||
|
|
||||||
|
if last_res is None:
|
||||||
|
return ''
|
||||||
node = optimize_all(context[last_res], rels, tostr=False)
|
node = optimize_all(context[last_res], rels, tostr=False)
|
||||||
return querysplit.split(node, rels)
|
return querysplit.split(node, rels)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class Relation:
|
|||||||
format as defined in RFC4180.
|
format as defined in RFC4180.
|
||||||
'''
|
'''
|
||||||
import csv
|
import csv
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w', newline='\n') as fp:
|
||||||
writer = csv.writer(fp) # Creating csv writer
|
writer = csv.writer(fp) # Creating csv writer
|
||||||
|
|
||||||
# It wants an iterable containing iterables
|
# It wants an iterable containing iterables
|
||||||
@ -193,7 +193,7 @@ class Relation:
|
|||||||
if eval(c_expr, attributes):
|
if eval(c_expr, attributes):
|
||||||
content.append(i)
|
content.append(i)
|
||||||
except Exception as e:
|
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))
|
return Relation(self.header, frozenset(content))
|
||||||
|
|
||||||
def product(self, other: 'Relation') -> 'Relation':
|
def product(self, other: 'Relation') -> 'Relation':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user