added debug print statement

can be triggered with "--debug" flag
This commit is contained in:
Jonas_Jones 2025-03-04 19:38:48 +01:00
parent 2ad0237335
commit 3307cb7377

View file

@ -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