from __future__ import annotations import json import re class Config: DEFAULT_FONT_FAMILY = "Ubuntu Mono" DEFAULT_FONT_SIZE = 16 ITALIC_FONT_FAMILY = "Ubuntu Mono" ITALIC_FONT_SIZE = 14 BACKGROUND_COLOR = [255, 255, 255] TEXT_COLOR = [0, 0, 0] LINK_COLOR = [0, 0, 0] BIT_I_COLOR = [0, 0, 0] BORDER_COLOR = [0, 0, 0] BIT_WIDTH = 30 BIT_HEIGHT = 30 DESCRIPTION_MARGIN = 10 DASH_LENGTH = 6 DASH_SPACE = 4 ARROW_SIZE = 10 MARGINS = [20, 20, 20, 20] ARROW_MARGIN = 4 VALUES_GAP = 5 ARROW_LABEL_DISTANCE = 5 FORCE_DESCS_ON_SIDE = False LEFT_LABELS = False WIDTH = 1200 HEIGHT = 800 def __init__(self, path: str = "config.json") -> None: self.load(path) @staticmethod def load(path: str) -> None: with open(path, "r") as f: config = json.load(f) for k, v in config.items(): k = Config.formatKey(k) if hasattr(Config, k): setattr(Config, k, v) @staticmethod def formatKey(key: str) -> str: return re.sub(r"([a-z])([A-Z])", r"\1_\2", key).upper()