Introducing variables for layout queries:

1.) The ExpressionContext class is a mapping of tl::Eval
    and allows providing a variable context for the LQ.
    Expression class is derived from ExpressionContext now.
2.) The variable lookup has been changed so that variables
    can be modified even if they come from a parent context.
3.) LayoutQuery and iterator has been given an argument to
    supply the context
This commit is contained in:
Matthias Koefferlein
2019-07-28 01:33:30 +02:00
parent 9a324727d2
commit 49c1bacb98
9 changed files with 102 additions and 52 deletions
+5
View File
@@ -24,6 +24,11 @@ class TLTest(unittest.TestCase):
def test_1(self):
ctx = pya.ExpressionContext()
self.assertEqual(ctx.eval("1+2"), 3)
ctx.var("a", 21)
self.assertEqual(ctx.eval("2*a"), 42)
expr = pya.Expression()
res = expr.eval()
self.assertEqual(str(type(res)).replace("class", "type"), "<type 'NoneType'>")