Пример #1
0
 def inner(self, *args):
     from types import GeneratorType
     from xotl.ql.interfaces import IQueryObject
     from xotl.ql.core import these
     query, rest = args[0], args[1:]
     if rest:
         raise SyntaxError('%s only accepts query expressions or query objects')
     if isinstance(query, GeneratorType):
         query = these(query)
     elif not IQueryObject.providedBy(query):
         raise SyntaxError('%s only accepts query expressions or query objects')
     plan = naive_translation(query, vm=dict(self.vm))
     return func(result for result in plan())
Пример #2
0
 def mergable(self, expression):
     'Returns true if `expression` is mergeable with the last captured part'
     from xoutil.compat import itervalues_
     assert context[UNPROXIFING_CONTEXT]
     is_expression = IExpressionTree.providedBy
     top = self._parts[-1]
     if top is expression:
         return True
     elif is_expression(expression):
         result = any(child is top for child in expression.children)
         if not result:
             return any(child is top
                        for child in itervalues_(expression.named_children))
         else:
             return result
     elif ITerm.providedBy(expression):
         return expression.parent is top
     elif IQueryObject.providedBy(expression):
         return False
     else:
         raise TypeError('Parts should be either these instance or '
                         'expression trees; not %s' % type(expression))