Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSSpecParser implementation for URI handling #27

Open
brl0 opened this issue Aug 4, 2021 · 5 comments
Open

FSSpecParser implementation for URI handling #27

brl0 opened this issue Aug 4, 2021 · 5 comments
Assignees
Labels
compatibility 🤝 Compatibility with stdlib pathlib

Comments

@brl0
Copy link
Contributor

brl0 commented Aug 4, 2021

Update: Python3.13 naming for "flavour" is now "parser", see ParserBase https://github.com/barneygale/pathlib-abc/blob/e429fd2ae079d3c623e687715a8133f4c4769ed2/pathlib_abc/__init__.py#L38

Issue

Starting new issue as requested based on comment in issue #26.

after digging deeper into the code, and exploring the pathlib implementation, I am wondering if UPath would benefit from having something like a _URI_Flavour derived from the pathlib._Flavour class. This might make it easier to have consistent path handling across the fsspec based implementations.

The base class: pathlib._Flavour

The posix implementation: pathlib._PosixFlavour

Here is a list of the members of the class for an idea of what may need to be implemented:

pathlib._PosixFlavour
  • altsep
  • casefold
  • casefold_parts
  • compile_pattern
  • gethomedir
  • has_drv
  • is_reserved
  • is_supported
  • join_parsed_parts
  • make_uri
  • parse_parts
  • pathmod
  • resolve
  • sep
  • splitroot

Of course it probably makes sense to base as much as possible on fsspec functionality, especially considering its ability for url chaining.
Here are some possibly related functions from fsspec.core:

  • _un_chain
  • url_to_fs
  • split_protocol
  • strip_protocol
@ap--
Copy link
Collaborator

ap-- commented Aug 28, 2023

A few notes regarding flavours:

With #114 coming up, future versions of universal_pathlib will probably derive from the pathlib.PathBase base class (probably available in python>=3.13). Support for older pythons (<3.13) will likely be provided through a backport of PathBase in pathlib2 (see: jazzband/pathlib2#70 (comment)) pathlib-abc (http://github.com/barneygale/pathlib-abc)

As far as I understand it, custom "flavour" implementations would then be equivalent to overriding PathBase.pathmod (see: python/cpython#106533) which is basically using a subset of the public interface of posixpath and ntpath.

This is relevant for providing support for urllib.parse.urljoin-like joining behavior.

@ap-- ap-- added the compatibility 🤝 Compatibility with stdlib pathlib label Aug 28, 2023
@merwok
Copy link

merwok commented Jan 4, 2024

See this message about the timeline and back/future-port of the ABC: drivendataorg/cloudpathlib#347 (comment)

@ap--
Copy link
Collaborator

ap-- commented Jan 17, 2024

It looks like we should implemenent our custom pathlib_abc.PathModuleBase for all Pythons when we start to rely on pathlib_abc

See: barneygale/pathlib-abc#19

@ap-- ap-- self-assigned this Jan 17, 2024
@ap--
Copy link
Collaborator

ap-- commented Jan 17, 2024

Note to self:

This should be relatively simple to achieve in the Python-3.12 support PR I have already drafted:

https://github.com/ap--/universal_pathlib/blob/2878bff22e32dbc5240766f51b3e7d31c00b4b9a/upath/core312plus.py#L38-L58

@ap-- ap-- changed the title pathlib._Flavour implementation for URI handling FSSpecFlavour implementation for URI handling Jan 28, 2024
@ap--
Copy link
Collaborator

ap-- commented Jan 28, 2024

see: python/cpython#114575

@ap-- ap-- changed the title FSSpecFlavour implementation for URI handling FSSpecParser implementation for URI handling Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility 🤝 Compatibility with stdlib pathlib
Projects
None yet
Development

No branches or pull requests

3 participants