Split the given conditional 'string' into its arguments.
(string)
| 26 | |
| 27 | |
| 28 | def _split_conditional(string): |
| 29 | """Split the given conditional 'string' into its arguments.""" |
| 30 | bracks_open = 0 |
| 31 | args = [] |
| 32 | carg = "" |
| 33 | escaped = False |
| 34 | for _idx, char in enumerate(string): |
| 35 | if char == "(": |
| 36 | if not escaped: |
| 37 | bracks_open += 1 |
| 38 | elif char == ")": |
| 39 | if not escaped: |
| 40 | bracks_open -= 1 |
| 41 | elif char == ":" and not bracks_open and not escaped: |
| 42 | args.append(carg) |
| 43 | carg = "" |
| 44 | escaped = False |
| 45 | continue |
| 46 | carg += char |
| 47 | escaped = not escaped if char == "\\" else False |
| 48 | args.append(carg) |
| 49 | return args |
| 50 | |
| 51 | |
| 52 | def _replace_conditional(match, string): |
no test coverage detected