forked from chekoduadarsh/BlocklyML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.py
31 lines (25 loc) · 938 Bytes
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
""" Python script with utility functions """
def strNoneConvert(input_data):
""" Converting input to string if it is not a list or none """
if input_data is None:
return None
if input_data is list:
return list
return str(input_data)
def floatNoneConvert(input_data):
""" Converting input to float if it is not a list or none """
if input_data is None or input_data == '':
return None
if input_data is list:
return list
return float(input_data)
def otherinputtodict(input_data):
""" Dict [parser funtion for other inputs """
input_parameter_dict = {}
if not input_data is None:
if "=" in input_data:
input_parameter_list = input_data.split(",")
for parameter in input_parameter_list:
input_parameter_dict[parameter.split(
"=")[0]] = parameter.split("=")[1]
return input_parameter_dict