Parse strings in the following format: [/flow-filter]/subject/replacement
(option: str)
| 2 | |
| 3 | |
| 4 | def parse_spec(option: str) -> tuple[flowfilter.TFilter, str, str]: |
| 5 | """ |
| 6 | Parse strings in the following format: |
| 7 | |
| 8 | [/flow-filter]/subject/replacement |
| 9 | |
| 10 | """ |
| 11 | sep, rem = option[0], option[1:] |
| 12 | parts = rem.split(sep, 2) |
| 13 | if len(parts) == 2: |
| 14 | subject, replacement = parts |
| 15 | return flowfilter.match_all, subject, replacement |
| 16 | elif len(parts) == 3: |
| 17 | patt, subject, replacement = parts |
| 18 | flow_filter = flowfilter.parse(patt) |
| 19 | return flow_filter, subject, replacement |
| 20 | else: |
| 21 | raise ValueError("Invalid number of parameters (2 or 3 are expected)") |
searching dependent graphs…