Python symbol.with_stmt() Examples

The following are 21 code examples of symbol.with_stmt(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module symbol , or try the search function .
Example #1
Source File: transformer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
Example #2
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
Example #3
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #4
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
Example #5
Source File: transformer.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #6
Source File: transformer.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' with_item (',' with_item)* ':' suite
        body = self.com_node(nodelist[-1])
        for i in range(len(nodelist) - 3, 0, -2):
            ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
            if i == 1:
                return ret
            body = ret 
Example #7
Source File: transformer.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #8
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
Example #9
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #10
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' expr [with_var] ':' suite
        expr = self.com_node(nodelist[1])
        body = self.com_node(nodelist[-1])
        if nodelist[2][0] == token.COLON:
            var = None
        else:
            var = self.com_assign(nodelist[2][2], OP_ASSIGN)
        return With(expr, var, body, lineno=nodelist[0][2]) 
Example #11
Source File: transformer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #12
Source File: transformer.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #13
Source File: transformer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #14
Source File: transformer.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' with_item (',' with_item)* ':' suite
        body = self.com_node(nodelist[-1])
        for i in range(len(nodelist) - 3, 0, -2):
            ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
            if i == 1:
                return ret
            body = ret 
Example #15
Source File: transformer.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #16
Source File: recipe-576404.py    From code with MIT License 5 votes vote down vote up
def _get_forbidden_symbols():
    """
    Returns a list of symbol codes representing statements that are *not*
    wanted in configuration files.
    """
    try:
        # Python 2.5:
        symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt,
                  symbol.decorator, symbol.decorators, symbol.eval_input,
                  symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt,
                  symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef,
                  symbol.global_stmt, symbol.import_as_name, symbol.import_as_names,
                  symbol.import_from, symbol.import_name, symbol.import_stmt,
                  symbol.lambdef, symbol.old_lambdef, symbol.print_stmt,
                  symbol.raise_stmt, symbol.try_stmt, symbol.while_stmt,
                  symbol.with_stmt, symbol.with_var, symbol.yield_stmt,
                  symbol.yield_expr]
        
    except AttributeError:
        # Python 2.4:        
        symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt,
                  symbol.decorator, symbol.decorators, symbol.eval_input,
                  symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt,
                  symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef,
                  symbol.global_stmt, symbol.import_as_name, symbol.import_as_names,
                  symbol.import_from, symbol.import_name, symbol.import_stmt,
                  symbol.lambdef, symbol.print_stmt, symbol.raise_stmt,
                  symbol.try_stmt, symbol.while_stmt]
    
    return symlst 
Example #17
Source File: transformer.py    From oss-ftp with MIT License 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' with_item (',' with_item)* ':' suite
        body = self.com_node(nodelist[-1])
        for i in range(len(nodelist) - 3, 0, -2):
            ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
            if i == 1:
                return ret
            body = ret 
Example #18
Source File: transformer.py    From oss-ftp with MIT License 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #19
Source File: transformer.py    From BinderFilter with MIT License 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' with_item (',' with_item)* ':' suite
        body = self.com_node(nodelist[-1])
        for i in range(len(nodelist) - 3, 0, -2):
            ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
            if i == 1:
                return ret
            body = ret 
Example #20
Source File: transformer.py    From BinderFilter with MIT License 5 votes vote down vote up
def with_stmt(self, nodelist):
        return self.com_with(nodelist) 
Example #21
Source File: transformer.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def com_with(self, nodelist):
        # with_stmt: 'with' with_item (',' with_item)* ':' suite
        body = self.com_node(nodelist[-1])
        for i in range(len(nodelist) - 3, 0, -2):
            ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
            if i == 1:
                return ret
            body = ret