From 3307cb73773ffce78d8edd26ce2614b21c55a354 Mon Sep 17 00:00:00 2001 From: Jonas_Jones Date: Tue, 4 Mar 2025 19:38:48 +0100 Subject: [PATCH] added debug print statement can be triggered with "--debug" flag --- puml_generator.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/puml_generator.py b/puml_generator.py index 8f06e01..0335a00 100644 --- a/puml_generator.py +++ b/puml_generator.py @@ -5,6 +5,18 @@ import os import re import sys +DEBUG_PRINTS = False + +def debug_print(*args, **kwargs) -> None: + """ + Print debug messages if the DEBUG_PRINTS flag is set to True. + + :param args: The positional arguments to print. + :param kwargs: The keyword arguments to print. + """ + if DEBUG_PRINTS: + print(*args, **kwargs) + def get_java_files(root_dir:str) -> list: """ Get all Java files in the root_dir and its subdirectories. @@ -62,6 +74,9 @@ def get_field_visibility(line): if match: # Check for the access modifier in the line and return the corresponding symbol split_line = line.split(" ") + + debug_print("FOUND FIELD WITH ACCESS MODIFIER:", split_line[0]) + if "public" in split_line: return "+" elif "private" in split_line: @@ -95,6 +110,9 @@ def get_method_visibility(line:str) -> str: if match: # Check for the access modifier in the line and return the corresponding symbol access_modifier = line.strip().split(" ")[0] + + debug_print("FOUND METHOD WITH ACCESS MODIFIER:", access_modifier) + if "public" in access_modifier: return "+" elif "private" in access_modifier: @@ -224,6 +242,9 @@ def class_to_puml(filename:str, base_package_slug:str) -> JavaClass: with open(filename, "r") as javafile: for javaline in javafile: javaline = javaline.strip() + + debug_print("LINE:", javaline) + if next_line_getter: if is_line_field_declaration(javaline): field_name = get_field_name_from_line(javaline) @@ -343,6 +364,9 @@ def get_arguments(argv: list) -> tuple: if "--dir" in argv: root_dir = argv[argv.index("--dir") + 1] no_pkgs = "--no-pkgs" in argv + + global DEBUG_PRINTS + DEBUG_PRINTS = "--debug" in argv return root_dir, no_pkgs