From e68cca76c614d38290186be17cb12ae783853be0 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Fri, 27 Dec 2024 15:40:49 -0800 Subject: [PATCH] Remove comfyui related prefix from node names. (#220) --- comfy_cli/registry/config_parser.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/comfy_cli/registry/config_parser.py b/comfy_cli/registry/config_parser.py index 2d4ca6d9..db904407 100644 --- a/comfy_cli/registry/config_parser.py +++ b/comfy_cli/registry/config_parser.py @@ -62,6 +62,30 @@ def create_comfynode_config(): raise Exception("Failed to write 'pyproject.toml'") from e +def sanitize_node_name(name: str) -> str: + """Remove common ComfyUI-related prefixes from a string. + + Args: + name: The string to process + + Returns: + The string with any ComfyUI-related prefix removed + """ + name = name.lower() + prefixes = [ + "comfyui-", + "comfyui_", + "comfy-", + "comfy_", + "comfy", + "comfyui", + ] + + for prefix in prefixes: + name = name.removeprefix(prefix) + return name + + def initialize_project_config(): create_comfynode_config() @@ -86,7 +110,7 @@ def initialize_project_config(): urls = project.get("urls", tomlkit.table()) urls["Repository"] = git_remote_url project["urls"] = urls - project["name"] = repo_name.lower() + project["name"] = sanitize_node_name(repo_name) project["description"] = "" project["version"] = "1.0.0"