Skip to content

Commit

Permalink
[Summarizable] Added printable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
YanSte committed Sep 8, 2023
1 parent efb5791 commit b05d45e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/skit/Summarizable.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
from abc import ABC, abstractmethod

class Summarizable(ABC):
def __init__(self, debug_mode=False):
self._debug_mode = debug_mode

def summary(self):
title = f"=== {self.__class__.__name__} Configuration Summary ==="
print(title)
self._print_sep()
print(f"\n{self.__class__.__name__} Configuration Summary\n")
for attr, value in self.__dict__.items():
print(f"{attr}: {value}")
print("=" * len(title))
self._print_sep()

def _debug(self, *args):
if self._debug_mode:
print(*args)

def _debug_sep(self, *args):
if self._debug_mode:
self._print_sep()

def _print_sep(self, character="=", length=40):
separator = character * length
print(separator)

0 comments on commit b05d45e

Please sign in to comment.