Try to guess whether a unicode query part is a path query. The path query must 1. precede the colon in the query, if a colon is present 2. contain either ``os.sep`` or ``os.altsep`` (Windows) 3. this path must exist on the filesystem.
(query_part: str)
| 326 | |
| 327 | @staticmethod |
| 328 | def is_path_query(query_part: str) -> bool: |
| 329 | """Try to guess whether a unicode query part is a path query. |
| 330 | |
| 331 | The path query must |
| 332 | 1. precede the colon in the query, if a colon is present |
| 333 | 2. contain either ``os.sep`` or ``os.altsep`` (Windows) |
| 334 | 3. this path must exist on the filesystem. |
| 335 | """ |
| 336 | query_part = query_part.split(":")[0] |
| 337 | |
| 338 | return ( |
| 339 | # make sure the query part contains a path separator |
| 340 | bool(set(query_part) & {os.sep, os.altsep}) |
| 341 | and os.path.exists(util.normpath(query_part)) |
| 342 | ) |
| 343 | |
| 344 | def match(self, obj: Model) -> bool: |
| 345 | """Check whether a model object's path matches this query. |