From 176be5867b838ae3c9a728325982197b8d99335e Mon Sep 17 00:00:00 2001 From: Victor Doval <10011941+vicdoval@users.noreply.github.com> Date: Sun, 28 Mar 2021 13:49:07 +0200 Subject: [PATCH 1/2] String tools 'number to string' mode --- nodes/text/string_tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nodes/text/string_tools.py b/nodes/text/string_tools.py index ae850f6384..2dec9b0d15 100644 --- a/nodes/text/string_tools.py +++ b/nodes/text/string_tools.py @@ -51,6 +51,7 @@ def find_all(text, chars): out.append(f) index=f+1 return out + def find_all_slice(text, chars, start, end): out =[] index=start @@ -64,10 +65,14 @@ def find_all_slice(text, chars, start, end): index=f+1 return out +def number_to_string(data, precision): + return ("{:." + str(precision) + "f}").format(float(data)) + func_dict = { "---------------OPS" : "#---------------------------------------------------#", "to_string": (0, str, ('t t'), "To String"), "to_number": (1, eval, ('t s'), "To Number"), + "num_to_str": (3, number_to_string , ('ss t'), "Number To String", ('Precision',)), "join": (5, lambda x, y: ''.join([x,y]), ('tt t'), "Join"), "join_all": (6, join, ('tb t'), "Join All", ('Add Break Lines',)), "split": (10, split, ('tcs t'), "Split", ('Spliter', 'Max Split')), From 250065a250e6b9b8d2abc52fc7be136e709a2c76 Mon Sep 17 00:00:00 2001 From: Victor Doval <10011941+vicdoval@users.noreply.github.com> Date: Sun, 28 Mar 2021 13:54:10 +0200 Subject: [PATCH 2/2] spacing fix --- nodes/text/string_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/text/string_tools.py b/nodes/text/string_tools.py index 2dec9b0d15..54c755bbb3 100644 --- a/nodes/text/string_tools.py +++ b/nodes/text/string_tools.py @@ -72,7 +72,7 @@ def number_to_string(data, precision): "---------------OPS" : "#---------------------------------------------------#", "to_string": (0, str, ('t t'), "To String"), "to_number": (1, eval, ('t s'), "To Number"), - "num_to_str": (3, number_to_string , ('ss t'), "Number To String", ('Precision',)), + "num_to_str": (3, number_to_string , ('ss t'), "Number To String", ('Precision',)), "join": (5, lambda x, y: ''.join([x,y]), ('tt t'), "Join"), "join_all": (6, join, ('tb t'), "Join All", ('Add Break Lines',)), "split": (10, split, ('tcs t'), "Split", ('Spliter', 'Max Split')),