Given a beets query string as a list of components, return the `Query` and `Sort` they represent. Like `dbcore.parse_sorted_query`, with beets query prefixes and ensuring that implicit path queries are made explicit with 'path:: '
(parts, model_cls)
| 12 | |
| 13 | |
| 14 | def parse_query_parts(parts, model_cls): |
| 15 | """Given a beets query string as a list of components, return the |
| 16 | `Query` and `Sort` they represent. |
| 17 | |
| 18 | Like `dbcore.parse_sorted_query`, with beets query prefixes and |
| 19 | ensuring that implicit path queries are made explicit with 'path::<query>' |
| 20 | """ |
| 21 | # Get query types and their prefix characters. |
| 22 | prefixes = { |
| 23 | ":": dbcore.query.RegexpQuery, |
| 24 | "=~": dbcore.query.StringQuery, |
| 25 | "=": dbcore.query.MatchQuery, |
| 26 | } |
| 27 | prefixes.update(plugins.queries()) |
| 28 | |
| 29 | # Special-case path-like queries, which are non-field queries |
| 30 | # containing path separators (/). |
| 31 | parts = [ |
| 32 | f"path:{s}" if dbcore.query.PathQuery.is_path_query(s) else s |
| 33 | for s in parts |
| 34 | ] |
| 35 | |
| 36 | case_insensitive = beets.config["sort_case_insensitive"].get(bool) |
| 37 | |
| 38 | query, sort = dbcore.parse_sorted_query( |
| 39 | model_cls, parts, prefixes, case_insensitive |
| 40 | ) |
| 41 | log.debug("Parsed query: {!r}", query) |
| 42 | log.debug("Parsed sort: {!r}", sort) |
| 43 | return query, sort |
| 44 | |
| 45 | |
| 46 | def parse_query_string(s, model_cls): |
no test coverage detected