parse string to number if possible e.g. "123" => 123 "12.2" => 12.3 "abc" => "abc" "$var" => "$var"
(str_value: Text)
| 20 | |
| 21 | |
| 22 | def parse_string_value(str_value: Text) -> Any: |
| 23 | """parse string to number if possible |
| 24 | e.g. "123" => 123 |
| 25 | "12.2" => 12.3 |
| 26 | "abc" => "abc" |
| 27 | "$var" => "$var" |
| 28 | """ |
| 29 | try: |
| 30 | return ast.literal_eval(str_value) |
| 31 | except ValueError: |
| 32 | return str_value |
| 33 | except SyntaxError: |
| 34 | # e.g. $var, ${func} |
| 35 | return str_value |
| 36 | |
| 37 | |
| 38 | def build_url(base_url, step_url): |
no outgoing calls
no test coverage detected