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

ENH: Add support for detecting write drivers using GDAL #270

Merged
merged 7 commits into from
Sep 6, 2023

Conversation

brendan-ward
Copy link
Member

Resolves #220
Supersedes #268

This adds support to use GDAL directly to detect supported write drivers based on a path, instead of using the hard-coded list we had previously.

This moves the detect_driver function to core; we may want to expose this as part of the public API for use in GeoPandas but I did not yet do so (let me know if this is a good idea).

As part of this, I had to rearrange a few things that are not part of the public API:

  • _preprocess_options_key_value moved to util.py to avoid a circular import issue; it is more utility-oriented anyway
  • DRIVERS was moved to the testing side, which is the only other place we were using it directly besides extension to driver detection. This wasn't part of the official public API, so hopefully this is not a breaking change, but we can mention it in the changelog if you think appropriate.

pyogrio/_ogr.pyx Outdated Show resolved Hide resolved
pyogrio/_ogr.pyx Outdated Show resolved Hide resolved
pyogrio/_ogr.pyx Show resolved Hide resolved
@theroggy
Copy link
Member

theroggy commented Aug 25, 2023

@brendan-ward sorry for the late review...

Looks nice!

I only try to support a handful of drivers, so not really important for me, but I'm doing some driver-specific stuff when writing in geofileops, so probably other people will do so as well? The detect_driver API is also pretty straightforward, so I also think it won't be difficult to keep it stable. Just not sure if it wouldn't be better to make it explicit in the function name that it will only return writable drivers?
Conclusion: exposing it as a public function sounds like a good idea to me, possibly with a slightly different name.

Probably it will be a good idea to revisit DRIVERS vs DRIVERS_EXT vs ALL_EXTS once upon a time now they are all only supporting the tests... but that's definitely not something for this PR.

@brendan-ward brendan-ward added this to the 0.7.0 milestone Sep 4, 2023
pyogrio/_ogr.pyx Outdated Show resolved Hide resolved
@brendan-ward brendan-ward merged commit aacd996 into main Sep 6, 2023
17 checks passed
@brendan-ward brendan-ward deleted the get_driver_ext branch September 6, 2023 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Auto-detect driver from filename extension when writing
2 participants