Skip to content

Commit

Permalink
refactor: extract message visibility logic into a separate method in …
Browse files Browse the repository at this point in the history
…Helper class
  • Loading branch information
csgoh committed Jan 20, 2025
1 parent 2f04093 commit ba9463f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/roadmapper/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ class Helper:
show_logo = False
show_timeline = True

@staticmethod
def should_show_message(show_level: str) -> bool:
return (
(show_level == "group" and Helper.show_group)
or (show_level == "task" and Helper.show_task)
or (show_level == "parallel_task" and Helper.show_parallel_task)
or (show_level == "milestone" and Helper.show_milestone)
or (show_level == "marker" and Helper.show_marker)
or (show_level == "title" and Helper.show_title)
or (show_level == "header" and Helper.show_header)
or (show_level == "footer" and Helper.show_footer)
or (show_level == "logo" and Helper.show_logo)
or (show_level == "timeline" and Helper.show_timeline)
)

@staticmethod
def printc(
message: str,
Expand All @@ -50,17 +65,9 @@ def printc(

root_logger = logging.getLogger()

if root_logger.getEffectiveLevel() == logging.DEBUG and (
(show_level == "group" and Helper.show_group)
or (show_level == "task" and Helper.show_task)
or (show_level == "parallel_task" and Helper.show_parallel_task)
or (show_level == "milestone" and Helper.show_milestone)
or (show_level == "marker" and Helper.show_marker)
or (show_level == "title" and Helper.show_title)
or (show_level == "header" and Helper.show_header)
or (show_level == "footer" and Helper.show_footer)
or (show_level == "logo" and Helper.show_logo)
or (show_level == "timeline" and Helper.show_timeline)
if (
root_logger.getEffectiveLevel() == logging.DEBUG
and Helper.should_show_message(show_level)
):
console = Console()
if rich_type == "text":
Expand Down

0 comments on commit ba9463f

Please sign in to comment.