How to use the gdtoolkit.formatter.check_formatting_safety function in gdtoolkit

To help you get started, we’ve selected a few gdtoolkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Scony / godot-gdscript-toolkit / tests / formatter / test_real_world_scripts.py View on Github external
def test_real_world_script_e2e(test_name):
    this_dir = os.path.dirname(os.path.abspath(__file__))
    input_file_path = os.path.join(this_dir, DATA_DIR, test_name)
    with open(input_file_path, "r") as input_fh:
        input_code = input_fh.read()
        formatted_code = format_code(input_code, 100)
        check_formatting_safety(input_code, formatted_code, 100)
github Scony / godot-gdscript-toolkit / gdtoolkit / formatter / __main__.py View on Github external
formatted_code = format_code(
                        gdscript_code=code,
                        max_line_length=line_length,
                        parse_tree=code_parse_tree,
                        comment_parse_tree=comment_parse_tree,
                    )
                except Exception as e:
                    print(
                        "exception during formatting of {}".format(file_path),
                        file=sys.stderr,
                    )
                    raise e
                if code != formatted_code:
                    print("would reformat {}".format(file_path), file=sys.stderr)
                    try:
                        check_formatting_safety(
                            code,
                            formatted_code,
                            max_line_length=line_length,
                            given_code_parse_tree=code_parse_tree,
                            given_code_comment_parse_tree=comment_parse_tree,
                        )
                    except Exception as e:
                        print(
                            "exception during formatting of {}".format(file_path),
                            file=sys.stderr,
                        )
                        raise e
                    formattable_files.add(file_path)
        if len(formattable_files) == 0:
            print(
                "{} file{} would be left unchanged".format(