示例#1
0
def unpack_infer(stmt, context=None):
    """return an iterator on nodes infered by the given statement
    if the infered value is a list or a tuple, recurse on it to
    get values infered by its content
    """
    if isinstance(stmt, (List, Tuple)):
        # XXX loosing context
        return chain(*imap(unpack_infer, stmt.nodes))
    infered = stmt.infer(context).next()
    if infered is stmt:
        return iter((stmt, ))
    return chain(*imap(unpack_infer, stmt.infer(context)))
示例#2
0
def unpack_infer(stmt, context=None):
    """return an iterator on nodes infered by the given statement
    if the infered value is a list or a tuple, recurse on it to
    get values infered by its content
    """
    if isinstance(stmt, (List, Tuple)):
        # XXX loosing context
        return chain(*imap(unpack_infer, stmt.nodes))
    infered = stmt.infer(context).next()
    if infered is stmt:
        return iter( (stmt,) )
    return chain(*imap(unpack_infer, stmt.infer(context)))
示例#3
0
 def _wrap_attr(self, attrs):
     """wrap bound methods of attrs in a InstanceMethod proxies"""
     # Guess which attrs are used in inference.
     def wrap(attr):
         if isinstance(attr, Function) and attr.type == 'method':
             return InstanceMethod(attr)
         else:
             return attr
     return imap(wrap, attrs)
示例#4
0
    def _wrap_attr(self, attrs):
        """wrap bound methods of attrs in a InstanceMethod proxies"""

        # Guess which attrs are used in inference.
        def wrap(attr):
            if isinstance(attr, Function) and attr.type == 'method':
                return InstanceMethod(attr)
            else:
                return attr

        return imap(wrap, attrs)