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

Changed upload_style so you can alternatively just pass valid XML in place of the path to the file containing the style XML #139

Merged
merged 9 commits into from
Feb 8, 2024

Conversation

iboates
Copy link
Collaborator

@iboates iboates commented Feb 5, 2024

Closes #116

I finally came back to this half a year later, but I made better changes than what I suggested in the issue.

You can now upload a style just by passing valid XML where you would normally pass the path to the SLD file.

I realize it's a bit janky because the parameter is called path, but I'm afraid that changing it might break existing systems that invoke the method via kwargs. But I think the added flexibility is worth it. To briefly re-iterate my issue, I was dynamically building style files on the fly and uploading them, and it was annoying me that I had to save them to a file before uploading them. With this change I (and others) should be able to just pass the style as XML if you don't want to bother writing to disk first.

I also wrote a couple tests to confirm that both passing a path to the file works, as does passing an XML string. I also tested that passing a non-existent path, as well as a malformed XML string fails as expected.

Sorry about the bad branch name, originally I was working on making temp files work before I realized that it would be easier to just pass a string.

Copy link
Collaborator

@iamtekson iamtekson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR. It looks good to me.

@iamtekson iamtekson merged commit 094407e into gicait:master Feb 8, 2024
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.

Support for uploading SLD files from an io.BytesIO object instead of just a path-like string
2 participants