Parse a glob pattern to a list of parts. This is much like _parse_path, except: - Rather than normalizing and returning the drive and root, we raise NotImplementedError if either are present. - If the path has no real parts, we raise ValueError. - If the pa
(cls, pattern)
| 301 | |
| 302 | @classmethod |
| 303 | def _parse_pattern(cls, pattern): |
| 304 | """Parse a glob pattern to a list of parts. This is much like |
| 305 | _parse_path, except: |
| 306 | |
| 307 | - Rather than normalizing and returning the drive and root, we raise |
| 308 | NotImplementedError if either are present. |
| 309 | - If the path has no real parts, we raise ValueError. |
| 310 | - If the path ends in a slash, then a final empty part is added. |
| 311 | """ |
| 312 | drv, root, rel = cls.parser.splitroot(pattern) |
| 313 | if root or drv: |
| 314 | raise NotImplementedError("Non-relative patterns are unsupported") |
| 315 | sep = cls.parser.sep |
| 316 | altsep = cls.parser.altsep |
| 317 | if altsep: |
| 318 | rel = rel.replace(altsep, sep) |
| 319 | parts = [x for x in rel.split(sep) if x and x != '.'] |
| 320 | if not parts: |
| 321 | raise ValueError(f"Unacceptable pattern: {str(pattern)!r}") |
| 322 | elif rel.endswith(sep): |
| 323 | # GH-65238: preserve trailing slash in glob patterns. |
| 324 | parts.append('') |
| 325 | return parts |
| 326 | |
| 327 | def as_posix(self): |
| 328 | """Return the string representation of the path with forward (/) |