Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #60
Adds method
client.forms.create
. There is a parameter for ignore_warnings which defaults to False. The publish parameter is hard coded to True as per #60. The form ID logic is slightly different, as follows - since pyODK has a form_id param and potentially a file path it seemed sensible to prioritise those before a uuid-based form ID fallback.form_id defaults behaviour for create/update:
Also since I anticipated this being used in pyxform-http or similar I made create/update accept bytes. So you could read in the request and send it off without writing to a file. I didn't add that for attachments but it could be done as well. I also had in mind Sam from HOT's recent request for pyxform to support passing in bytes in addition to paths.
What has been done to verify that this works as intended?
Unit tests and E2E tests. Manually verified valid forms were uploaded.
Why is this the best possible solution? Were any other approaches considered?
If the bytes thing seems too much, it's pretty much contained to 36fe156 so that could be dropped if preferred.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
New method to create forms. For update, the
definition
kwarg now accepts PathLike or bytes in addition to a string path.Do we need any specific form for testing your changes? If so, please attach one.
No, this PR pulls in
xlwt
as a dependency for XLS files so we can steadfastly not add binary test fixtures. On the XLS topic, I vendorised (but credited in comments) an external XLS detection function.Does this change require updates to documentation? If so, please file an issue here and include the link below.
The auto-generated docs would show the new methods.
Before submitting this PR, please make sure you have:
tests
python -m unittest
and verified all tests passruff format pyxform tests
andruff check pyxform tests
to lint code