"""Utility helpers for retrieving the current metadata system version.""" import os from functools import lru_cache @lru_cache(maxsize=1) def get_metadata_system_version() -> str: """Return the metadata system version string from version.txt or fallbacks.""" base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) version_file = os.path.join(base_dir, "version.txt") try: with open(version_file, "r", encoding="utf-8") as handle: version = handle.read().strip() if version: return version except OSError: pass try: from custom_nodes.AAA_Metadata_System import __version__ # type: ignore if __version__: return str(__version__) except Exception: pass return "unknown" def get_metadata_system_version_label(prefix: str = "ComfyUI Metadata System") -> str: """Return a human-friendly "generated by" string using the current version.""" version = get_metadata_system_version() lower_version = version.lower() if lower_version.startswith("v"): return f"{prefix} {version}" if version == "unknown": return f"{prefix} (version unknown)" return f"{prefix} v{version}"