From d5c64af68369caf0dbf411950e6c73c01731c409 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 11 Nov 2026 09:22:36 +0100 Subject: [PATCH] enum_helper.py: Import the name conversion helpers from jw-pkg kebab_to_pascal() and pascal_to_kebab() are needed in jw-pkg, for the resolution of filter names and, later, the dynamic loading of file contexts. jw-python depends on jw-pkg, so jw-pkg's util.py is their canonical home. This commit imports them from jw.pkg.lib.util and re-exports them, so the existing importers keep working. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.2 Signed-off-by: Jan Lindemann --- src/python/jw/util/enum_helper.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/python/jw/util/enum_helper.py b/src/python/jw/util/enum_helper.py index fb2a409..ccfc94c 100644 --- a/src/python/jw/util/enum_helper.py +++ b/src/python/jw/util/enum_helper.py @@ -1,22 +1,20 @@ from __future__ import annotations -import re - from typing import TYPE_CHECKING +from jw.pkg.lib.util import kebab_to_pascal, pascal_to_kebab + if TYPE_CHECKING: from enum import Enum from typing import TypeVar EnumType = TypeVar("EnumType", bound = Enum) -def kebab_to_pascal(value: str) -> str: - return "".join(part.capitalize() for part in value.split("-")) - -def pascal_to_kebab(value: str) -> str: - # Handles normal CamelCase / PascalCase, including many acronym cases - s1 = re.sub(r"(.)([A-Z][a-z]+)", r"\1-\2", value) - s2 = re.sub(r"([a-z0-9])([A-Z])", r"\1-\2", s1) - return s2.lower() +__all__ = [ + "kebab_to_pascal", + "pascal_to_kebab", + "enum_from_kebab", + "enum_to_kebab", +] def enum_from_kebab(enum_cls: type[EnumType], value: str) -> EnumType: return enum_cls[kebab_to_pascal(value)] -- 2.56.1