From d687497d8041ab5d77bd31909592def6e4d0e7f6 Mon Sep 17 00:00:00 2001 From: Mel Massadian Date: Wed, 3 Jul 2024 16:00:48 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A7=B9=20better=20classname=20ex?= =?UTF-8?q?traction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow for consecutive uppercase letters: - MTB_BatchFromHistoryV2 -> Batch From History V2 - MTB_CLIPInterpolate -> CLIP Interpolate --- __init__.py | 2 +- log.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index c1a56a6..f6811dd 100644 --- a/__init__.py +++ b/__init__.py @@ -179,7 +179,7 @@ for node_class in nodes: node_class.DESCRIPTION = node_class.__doc__ if MTB_EXPORT: wiki_name = classname_to_wiki(class_name) - (wiki / "nodes" / wiki_name + ".md").write_text( + (wiki / "nodes" / (wiki_name + ".md")).write_text( node_class.__doc__, encoding="utf-8" ) diff --git a/log.py b/log.py index 06473ac..76b42e4 100644 --- a/log.py +++ b/log.py @@ -77,5 +77,11 @@ def cyan_text(text: str): def get_label(label: str): if label.startswith("MTB_"): label = label[4:] - words = re.findall(r"(?:^|[A-Z])[a-z]*", label) + + words = re.findall( + r"(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z]))", + label, + ) + reformatted_label = re.sub(r"([A-Z]+)", r" \1", label).strip() + words = reformatted_label.split() return " ".join(words).strip()