MCPcopy Create free account
hub / github.com/DanielPFlorian/ComfyUI-WorkflowGenerator / format

Function format

utils/process_utils.py:10–32  ·  view source on GitHub ↗

Format node type by removing the last underscore and everything after it. Also handles node names with parentheses (e.g., "Node Name (author)"). Args: node_type: Node type string (e.g., "CheckpointLoaderSimple_1" or "SDXL Empty Latent Image (rgthree)") Returns: For

(node_type: str)

Source from the content-addressed store, hash-verified

8
9
10def format(node_type: str) -> str:
11 """
12 Format node type by removing the last underscore and everything after it.
13 Also handles node names with parentheses (e.g., "Node Name (author)").
14
15 Args:
16 node_type: Node type string (e.g., "CheckpointLoaderSimple_1" or "SDXL Empty Latent Image (rgthree)")
17
18 Returns:
19 Formatted node type (e.g., "CheckpointLoaderSimple" or "SDXL Empty Latent Image (rgthree)")
20
21 Note:
22 - If node type contains underscore, removes suffix (e.g., "NodeName_0" -> "NodeName")
23 - If node type contains parentheses, keeps as-is (e.g., "Node Name (author)" -> "Node Name (author)")
24 - If node type has neither, returns as-is
25 """
26 last_index = node_type.rfind("_")
27 if last_index != -1:
28 suffix = node_type[last_index + 1 :]
29 if suffix.isdigit() or (len(suffix) <= 2 and suffix.isalnum()):
30 result = node_type[:last_index]
31 return result
32 return node_type
33
34
35def del_digram_primitive(digram: list[list[str]]) -> list[list[str]]:

Callers 3

del_digram_primitiveFunction · 0.85
refine_diagramMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected