(self)
return ret
Returns a list of 2-tuples (condition, value).

        If an ELSE exists condition is None.
Returns a list of 2-tuples (condition, value).
Returns a list of 2 - tuples ( condition value ) .
def get_cases(self):
        """Returns a list of 2-tuples (condition, value).

        If an ELSE exists condition is None.
        """
        ret = []
        in_value = False
        in_condition = True
        for token in self.tokens:
            if token.match(T.Keyword, 'CASE'):
                continue
            elif token.match(T.Keyword, 'WHEN'):
                ret.append(([], []))
                in_condition = True
                in_value = False
            elif token.match(T.Keyword, 'ELSE'):
                ret.append((None, []))
                in_condition = False
                in_value = True
            elif token.match(T.Keyword, 'THEN'):
                in_condition = False
                in_value = True
            elif token.match(T.Keyword, 'END'):
                in_condition = False
                in_value = False
            if (in_condition or in_value) and not ret:
                # First condition withou preceding WHEN
                ret.append(([], []))
            if in_condition:
                ret[-1][0].append(token)
            elif in_value:
                ret[-1][1].append(token)
        return ret
def get_cases ( self ) : ret = [ ] in_value = False in_condition = True for token in self . tokens : if token . match ( T . Keyword , 'CASE' ) : continue elif token . match ( T . Keyword , 'WHEN' ) : ret . append ( ( [ ] , [ ] ) ) in_condition = True in_value = False elif token . match ( T . Keyword , 'ELSE' ) : ret . append ( ( None , [ ] ) ) in_condition = False in_value = True elif token . match ( T . Keyword , 'THEN' ) : in_condition = False in_value = True elif token . match ( T . Keyword , 'END' ) : in_condition = False in_value = False if ( in_condition or in_value ) and not ret : # First condition withou preceding WHEN ret . append ( ( [ ] , [ ] ) ) if in_condition : ret [ - 1 ] [ 0 ] . append ( token ) elif in_value : ret [ - 1 ] [ 1 ] . append ( token ) return ret