Returns a FmtStr object from a bpython-formatted colored string
(s: str)
| 48 | |
| 49 | |
| 50 | def parse(s: str) -> FmtStr: |
| 51 | """Returns a FmtStr object from a bpython-formatted colored string""" |
| 52 | rest = s |
| 53 | stuff = [] |
| 54 | while rest: |
| 55 | start, rest = peel_off_string(rest) |
| 56 | stuff.append(start) |
| 57 | return ( |
| 58 | sum((fs_from_match(d) for d in stuff[1:]), fs_from_match(stuff[0])) |
| 59 | if len(stuff) > 0 |
| 60 | else FmtStr() |
| 61 | ) |
| 62 | |
| 63 | |
| 64 | def fs_from_match(d: dict[str, Any]) -> FmtStr: |
no test coverage detected