Skip to content
Snippets Groups Projects
Commit 78b4d76e authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improved AUTO handling. Made safe-cell logic auto generated

parent b8f8b8e8
No related branches found
No related tags found
No related merge requests found
......@@ -17,23 +17,26 @@ class PlutoVariables:
pass
def codegen(self, expr):
m = re.match('([^=]+)=AND\{(.*),(.*)\}', expr)
m = re.match('([^=]+)=(AND|OR)\{(.*),(.*)\}', expr)
if m:
lh = m.group(1)
regexp = m.group(2).replace('*', '.*')
rh = [ m.group(3).format(v, pluto=self.by_name[v][0])
for v in self.by_name if re.match(regexp, v)]
op = m.group(2)
regexp = m.group(3).replace('*', '.*')
expr = m.group(4)
rh = []
for k,v in sorted(self.by_name.items()):
rh_m = re.match(regexp, k)
if rh_m:
matches = (k,)+rh_m.groups()
rh.append(expr.format(*matches, pluto=v[0]))
pass
pass
if op == 'AND':
return("%s=%s" % (lh, '*'.join(rh)))
m = re.match('([^=]+)=OR\{(.*),(.*)\}', expr)
if m:
lh = m.group(1)
regexp = m.group(2).replace('*', '.*')
rh = [ m.group(3).format(v, pluto=self.by_name[v][0])
for v in self.by_name if re.match(regexp, v)]
elif op == 'OR':
return("%s=%s" % (lh, '+'.join(rh)))
raise Exception('Invalid expression', expr)
class SPS:
def __init__(self, path):
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment