def parse_expression(source: str) -> ExpressionSource:
    '''Returns tuple with expression type and expression body'''
    if not is_expression(source):
        msg = 'Expression is not valid. Expression should be matched with regular expression: {0}'\
              .format(EXPRESSION_REGEX)
        raise ExpressionError(msg, source)
    if not source.startswith('{'):
        [type_, source] = source.split(':', 1)
    elif source.endswith('}}'):
        type_ = 'twoways'
    else:
        type_ = 'oneway'
    return (type_, source[1:-1])
def parse_expression ( source : str ) -> ExpressionSource : if not is_expression ( source ) : msg = 'Expression is not valid. Expression should be matched with regular expression: {0}' . format ( EXPRESSION_REGEX ) raise ExpressionError ( msg , source ) if not source . startswith ( '{' ) : [ type_ , source ] = source . split ( ':' , 1 ) elif source . endswith ( '}}' ) : type_ = 'twoways' else : type_ = 'oneway' return ( type_ , source [ 1 : - 1 ] )
Returns tuple with expression type and expression body