Python symbol 模块,list_iter() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用symbol.list_iter()

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def com_list_iter(self, node):
        assert node[0] == symbol.list_iter
        return node[1]
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def com_list_iter(self, node):
        assert node[0] == symbol.list_iter
        return node[1]
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def com_list_iter(self, node):
        assert node[0] == symbol.list_iter
        return node[1]
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def com_list_iter(self, node):
        assert node[0] == symbol.list_iter
        return node[1]
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def com_list_iter(self, node):
        assert node[0] == symbol.list_iter
        return node[1]
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def com_comprehension(self, expr1, expr2, node, type):
        # list_iter: list_for | list_if
        # list_for: 'for' exprlist 'in' testlist [list_iter]
        # list_if: 'if' test [list_iter]

        # XXX should raise SyntaxError for assignment
        # XXX(avassalotti) Set and dict comprehensions should have generator
        #                  semantics. In other words, they shouldn't leak
        #                  variables outside of the comprehension's scope.

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                compNode = self.com_node(node[4])
                newfor = ListCompFor(assignNode, compNode, [])
                newfor.lineno = node[1][2]
                fors.append(newfor)
                if len(node) == 5:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[5])
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = ListCompIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[3])
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                      ("unexpected comprehension element: %s %d"
                       % (node, lineno))
        if type == 'list':
            return ListComp(expr1, fors, lineno=lineno)
        elif type == 'set':
            return SetComp(expr1, fors, lineno=lineno)
        elif type == 'dict':
            return DictComp(expr1, expr2, fors, lineno=lineno)
        else:
            raise ValueError("unexpected comprehension type: " + repr(type))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def com_comprehension(self, expr1, expr2, node, type):
        # list_iter: list_for | list_if
        # list_for: 'for' exprlist 'in' testlist [list_iter]
        # list_if: 'if' test [list_iter]

        # XXX should raise SyntaxError for assignment
        # XXX(avassalotti) Set and dict comprehensions should have generator
        #                  semantics. In other words, they shouldn't leak
        #                  variables outside of the comprehension's scope.

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                compNode = self.com_node(node[4])
                newfor = ListCompFor(assignNode, compNode, [])
                newfor.lineno = node[1][2]
                fors.append(newfor)
                if len(node) == 5:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[5])
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = ListCompIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[3])
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                      ("unexpected comprehension element: %s %d"
                       % (node, lineno))
        if type == 'list':
            return ListComp(expr1, fors, lineno=lineno)
        elif type == 'set':
            return SetComp(expr1, fors, lineno=lineno)
        elif type == 'dict':
            return DictComp(expr1, expr2, fors, lineno=lineno)
        else:
            raise ValueError("unexpected comprehension type: " + repr(type))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def com_comprehension(self, expr1, expr2, node, type):
        # list_iter: list_for | list_if
        # list_for: 'for' exprlist 'in' testlist [list_iter]
        # list_if: 'if' test [list_iter]

        # XXX should raise SyntaxError for assignment
        # XXX(avassalotti) Set and dict comprehensions should have generator
        #                  semantics. In other words, they shouldn't leak
        #                  variables outside of the comprehension's scope.

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                compNode = self.com_node(node[4])
                newfor = ListCompFor(assignNode, compNode, [])
                newfor.lineno = node[1][2]
                fors.append(newfor)
                if len(node) == 5:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[5])
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = ListCompIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[3])
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                      ("unexpected comprehension element: %s %d"
                       % (node, lineno))
        if type == 'list':
            return ListComp(expr1, fors, lineno=lineno)
        elif type == 'set':
            return SetComp(expr1, fors, lineno=lineno)
        elif type == 'dict':
            return DictComp(expr1, expr2, fors, lineno=lineno)
        else:
            raise ValueError("unexpected comprehension type: " + repr(type))
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def com_comprehension(self, expr1, expr2, node, type):
        # list_iter: list_for | list_if
        # list_for: 'for' exprlist 'in' testlist [list_iter]
        # list_if: 'if' test [list_iter]

        # XXX should raise SyntaxError for assignment
        # XXX(avassalotti) Set and dict comprehensions should have generator
        #                  semantics. In other words, they shouldn't leak
        #                  variables outside of the comprehension's scope.

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                compNode = self.com_node(node[4])
                newfor = ListCompFor(assignNode, compNode, [])
                newfor.lineno = node[1][2]
                fors.append(newfor)
                if len(node) == 5:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[5])
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = ListCompIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[3])
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                      ("unexpected comprehension element: %s %d"
                       % (node, lineno))
        if type == 'list':
            return ListComp(expr1, fors, lineno=lineno)
        elif type == 'set':
            return SetComp(expr1, fors, lineno=lineno)
        elif type == 'dict':
            return DictComp(expr1, expr2, fors, lineno=lineno)
        else:
            raise ValueError("unexpected comprehension type: " + repr(type))
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def com_comprehension(self, expr1, expr2, node, type):
        # list_iter: list_for | list_if
        # list_for: 'for' exprlist 'in' testlist [list_iter]
        # list_if: 'if' test [list_iter]

        # XXX should raise SyntaxError for assignment
        # XXX(avassalotti) Set and dict comprehensions should have generator
        #                  semantics. In other words, they shouldn't leak
        #                  variables outside of the comprehension's scope.

        lineno = node[1][2]
        fors = []
        while node:
            t = node[1][1]
            if t == 'for':
                assignNode = self.com_assign(node[2], OP_ASSIGN)
                compNode = self.com_node(node[4])
                newfor = ListCompFor(assignNode, compNode, [])
                newfor.lineno = node[1][2]
                fors.append(newfor)
                if len(node) == 5:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[5])
                else:
                    node = self.com_comp_iter(node[5])
            elif t == 'if':
                test = self.com_node(node[2])
                newif = ListCompIf(test, lineno=node[1][2])
                newfor.ifs.append(newif)
                if len(node) == 3:
                    node = None
                elif type == 'list':
                    node = self.com_list_iter(node[3])
                else:
                    node = self.com_comp_iter(node[3])
            else:
                raise SyntaxError, \
                      ("unexpected comprehension element: %s %d"
                       % (node, lineno))
        if type == 'list':
            return ListComp(expr1, fors, lineno=lineno)
        elif type == 'set':
            return SetComp(expr1, fors, lineno=lineno)
        elif type == 'dict':
            return DictComp(expr1, expr2, fors, lineno=lineno)
        else:
            raise ValueError("unexpected comprehension type: " + repr(type))