Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String tools 'number to string' mode #3998

Merged
merged 2 commits into from
Mar 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions nodes/text/string_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')),
Expand Down