How to use the pynq.expressions.GetAttributeExpression function in pynq

To help you get started, we’ve selected a few pynq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heynemann / pynq / tests / unit / test_get_attribute_expression.py View on Github external
def test_get_attribute_returns_the_proper_representation(self):
        expression = GetAttributeExpression(GetAttributeExpression("some","weird"), "expression")
        assert str(expression) == "some.weird.expression"
github heynemann / pynq / tests / unit / test_pynq_factory.py View on Github external
def test_where_binary_equals_returns_get_attribute_expression_on_lhs(self):
        col = []
        tree = From(col).where("some.other.property == 'Bernardo'")
        error = "Lhs should be GetAttributeExpression but was %s"
        class_name = tree.expressions[0].__class__.__name__
        assert isinstance(tree.expressions[0].lhs, GetAttributeExpression), \
                            error % class_name
github heynemann / pynq / tests / unit / test_get_attribute_expression.py View on Github external
def test_get_attribute_expression_validates_against_empty_attributes(self):
        self.assertRaisesEx(ValueError, GetAttributeExpression, exc_pattern=re.compile("In order to create a new attribute expression you need to provide some attributes."))
github heynemann / pynq / tests / unit / test_get_attribute_expression.py View on Github external
def test_nested_get_attribute_expressions_work_together(self):
        expression = GetAttributeExpression(GetAttributeExpression("some","weird"), "expression")
        assert len(expression.attributes) == 3
        assert expression.attributes[0] == "some"
        assert expression.attributes[1] == "weird"
        assert expression.attributes[2] == "expression"
github heynemann / pynq / tests / unit / test_get_attribute_expression.py View on Github external
def test_get_attribute_expression_keeps_track_of_attributes(self):
        expression = GetAttributeExpression("some","expression")
        assert len(expression.attributes) == 2, "Length of attributes property should be 2 but was %d" % len(expression.attributes)
        assert expression.attributes[0] == "some"
        assert expression.attributes[1] == "expression"
github heynemann / pynq / pynq / expressions.py View on Github external
def add_attributes(self, attrs):
        for attr in attrs:
            if isinstance(attr, GetAttributeExpression):
                self.add_attributes(attr.attributes)
            else:
                self.attributes.append(attr)
github heynemann / pynq / pynq / parser.py View on Github external
def led(self, left):
        first = left
        second = token
        if not isinstance(second, NameToken):
            error = u"Each part of a given get attribute expression (some.variable.value) needs to be a NameExpression."
            raise ValueError(error)
        second = NameExpression(second.value)
        self.advance()
        
        return GetAttributeExpression(first, second)