Coverage for /Users/fmorton/GitHub/BirdBrain-Python-Library-2/src/birdbrain_utility.py: 100%
29 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-12 11:24 -0400
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-12 11:24 -0400
1class BirdbrainUtility:
2 @classmethod
3 def is_none_or_empty(self, s):
4 if s is None or s == "":
5 return True
6 else:
7 return False
9 @classmethod
10 def bounds(self, input, input_min, input_max, pass_through_input = None):
11 #if pass_through_input is not None and (input == pass_through_input): return int(input)
13 if int(input) < int(input_min): return int(input_min)
14 if int(input) > int(input_max): return int(input_max)
16 return int(input)
18 @classmethod
19 def decimal_bounds(self, input, input_min, input_max, pass_through_input = None):
20 #if pass_through_input is not None and (input == pass_through_input): return int(input)
22 if float(input) < float(input_min): return float(input_min)
23 if float(input) > float(input_max): return float(input_max)
25 return float(input)
28 @classmethod
29 def flatten_string(self, original_list, divider = "/"):
30 if isinstance(original_list[0], list): original_list = original_list[0]
32 original_list = [item for item in original_list]
34 s = ""
35 for element in list(original_list):
36 if isinstance(element, str):
37 s += str(element) + divider
38 elif isinstance(element, int):
39 s += str(element) + divider
40 else:
41 for sub_element in element:
42 s += str(sub_element) + divider
44 return(s[:-1])