Merge pull request #3 from xegim/floatconv
Add float to string conversion node
This commit is contained in:
+3
-1
@@ -1,5 +1,5 @@
|
||||
from .nodes.combiner import ETSplitTextNode, ETJoinTextNode, ETSwitchTextNode
|
||||
from .nodes.converter import ETATOI, ETITOA
|
||||
from .nodes.converter import ETATOI, ETITOA, ETFTOA
|
||||
from .nodes.formatter import ETTextFormatter2Node, ETTextFormatter5Node, ETTextFormatter10Node
|
||||
from .nodes.replacer import ETReplaceTextNode
|
||||
|
||||
@@ -10,6 +10,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
|
||||
"ETATOI": ETATOI,
|
||||
"ETITOA": ETITOA,
|
||||
"ETFTOA": ETFTOA,
|
||||
|
||||
"ETTextFormatter2Node": ETTextFormatter2Node,
|
||||
"ETTextFormatter5Node": ETTextFormatter5Node,
|
||||
@@ -25,6 +26,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
|
||||
"ETATOI": "ATOI",
|
||||
"ETITOA": "ITOA",
|
||||
"ETFTOA": "FTOA",
|
||||
|
||||
"ETTextFormatter2Node": "Text Formatter (2 Arguments)",
|
||||
"ETTextFormatter5Node": "Text Formatter (5 Arguments)",
|
||||
|
||||
@@ -42,3 +42,26 @@ class ETITOA:
|
||||
|
||||
def process(self, integer: int) -> tuple:
|
||||
return (str(integer),)
|
||||
|
||||
class ETFTOA:
|
||||
"""
|
||||
A node that converts a float to a string.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"value": ("FLOAT", {"default": 0.0, "min": -2000000000, "max": 2000000000}),
|
||||
"decimals": ("INT", {"default": 3, "min": 0, "max": 8}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("text",)
|
||||
|
||||
CATEGORY = "exectails/Strings"
|
||||
FUNCTION = "process"
|
||||
|
||||
def process(self, value: float, decimals: int) -> tuple:
|
||||
return ("{:.{}f}".format(value,decimals),)
|
||||
|
||||
Reference in New Issue
Block a user