Given a beets query string, return the `Query` and `Sort` they represent. The string is split into components using shell-like syntax.
(s, model_cls)
| 44 | |
| 45 | |
| 46 | def parse_query_string(s, model_cls): |
| 47 | """Given a beets query string, return the `Query` and `Sort` they |
| 48 | represent. |
| 49 | |
| 50 | The string is split into components using shell-like syntax. |
| 51 | """ |
| 52 | message = f"Query is not unicode: {s!r}" |
| 53 | assert isinstance(s, str), message |
| 54 | try: |
| 55 | parts = shlex.split(s) |
| 56 | except ValueError as exc: |
| 57 | raise dbcore.InvalidQueryError(s, exc) |
| 58 | return parse_query_parts(parts, model_cls) |