cpython icon indicating copy to clipboard operation
cpython copied to clipboard

GH-114575: Rename `PurePath.pathmod` to `PurePath.parser`

Open barneygale opened this issue 1 year ago • 1 comments

And rename the private base class from PathModuleBase to ParserBase.

No news or deprecation period needed as this attribute is new in 3.13.

  • Downstream issue: https://github.com/barneygale/pathlib-abc/issues/19
  • Issue: gh-114575

📚 Documentation preview 📚: https://cpython-previews--116513.org.readthedocs.build/

barneygale avatar Mar 08 '24 19:03 barneygale

For ease of reference, here's the API:

class ParserBase:
    """Base class for path parsers, which do low-level path manipulation."""

    @property
    def sep(self) --> str:
        """The character used to separate path components."""

    def join(self, path: str, *paths: str) -> str:
        """Join path segments."""

    def split(self, path: str) -> tuple[str, str]:
        """Split the path into a pair (head, tail), where *head* is everything
        before the final path separator, and *tail* is everything after.
        Either part may be empty.
        """

    def splitdrive(self, path: str) -> tuple[str, str]:
        """Split the path into a 2-item tuple (drive, tail), where *drive* is
        a device name or mount point, and *tail* is everything after the
        drive. Either part may be empty."""

    def normcase(self, path: str) -> str:
        """Normalize the case of the path."""

    def isabs(self, path: str) -> bool:
        """Returns whether the path is absolute, i.e. unaffected by the
        current directory or drive."""

We may add splitext() at some point.

barneygale avatar Mar 10 '24 19:03 barneygale