Пример #1
0
 def validate(self, node):
     '''
     Check this constraint against a node.
     Raise an exception if the constraint fails, possibly after attempting fixup
     '''
     from amara.bindery import BinderyError
     assertion = self.assertion
     if callable(assertion):
         assertion = assertion(node)
     result = datatypes.boolean(node.xml_select(assertion))
     if not result:
         if self.fixup:
             self.fixup(node)
             result = datatypes.string(node.xml_select(assertion))
             if result:
                 return
         raise BinderyError(BinderyError.CONSTRAINT_VIOLATION, constraint=self.msg or assertion, node=abspath(node))
Пример #2
0
 def validate(self, node):
     '''
     Check this constraint against a node.
     Raise an exception if the constraint fails, possibly after attempting fixup
     '''
     from amara.bindery import BinderyError
     assertion = self.assertion
     if callable(assertion):
         assertion = assertion(node)
     result = datatypes.boolean(node.xml_select(assertion))
     if not result:
         if self.fixup:
             self.fixup(node)
             result = datatypes.string(node.xml_select(assertion))
             if result:
                 return
         raise BinderyError(BinderyError.CONSTRAINT_VIOLATION,
                            constraint=self.msg or assertion,
                            node=abspath(node))
Пример #3
0
 def evaluate_as_boolean(self, context):
     return datatypes.boolean(self.evaluate(context))
Пример #4
0
 def evaluate_as_boolean(self, context):
     return datatypes.boolean(self.evaluate(context))