Beispiel #1
0
def _multiline_settings(len_limit, multiline):
    if not multiline:
        len_limit = 0
        lexer.set_single_line()
    else:
        lexer.set_multiline()
    return len_limit
Beispiel #2
0
def fstringify_code_by_line(code: str,
                            multiline=True,
                            len_limit=79) -> Tuple[str, int]:
    """ returns fstringified version of the code and amount of lines edited."""
    if not multiline:
        len_limit = 0
        lexer.set_single_line()
    else:
        lexer.set_multiline()

    jt = JoinTransformer(code, len_limit)

    return jt.fstringify_code_by_line()
Beispiel #3
0
def fstringify_concats(code: str,
                       multiline=True,
                       len_limit=88) -> Tuple[str, int]:
    """ returns fstringified version of the code and amount of lines edited."""
    if not multiline:
        len_limit = 0
        lexer.set_single_line()
    else:
        lexer.set_multiline()

    jt = JoinTransformer(
        code,
        len_limit,
        candidates_constructor=concat_candidates,
        transform_func=transform_concat,
    )

    return jt.fstringify_code_by_line()