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)
| 8 | |
| 9 | |
| 10 | def 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 | |
| 35 | def del_digram_primitive(digram: list[list[str]]) -> list[list[str]]: |
no outgoing calls
no test coverage detected