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

Patch for a shorthand definition of quoted fields in http_urllib #691

Closed
wants to merge 4 commits into from

Conversation

otdftr
Copy link
Contributor

@otdftr otdftr commented Feb 6, 2024

When working with a greater number of transformed fields (e. g. through topic's alldata), the params definition for the target has a lot of redundancy, especially when the field names are crafted to be the parameter names of the query parameters:

This patch provides a shorthand for a definition like
[ #method, #url, { 'param1' : '@param1', ..., 'paramN': '@paramN' }, ...
by allowing lists for the 3rd parameter of the target definition:
[ #method, #url, [ '?param1', ..., '?paramN' ], ...

If a list is provided

  • the given names will be used as both keys do item.data{} and query parameter names
  • they will be added as quoted fields, regardless of whether the @-prefix is provided: [ 'param1', ..., 'paramN' ] will be interpreted as [ '@param1', ..., '@paramN' ]
  • with the prefix ?, fields can be declared optional: they will not be included in the query if the data is invalid or missing from item.data{}; [ 'param1', '?param2', ... ]

add list shorthand for params dict + allow optional params in query string
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (9d61fc5) 49.75% compared to head (aac55eb) 49.60%.

❗ Current head aac55eb differs from pull request most recent head 675fbb0. Consider uploading reports for the commit 675fbb0 to get more accurate results

Files Patch % Lines
mqttwarn/services/http_urllib.py 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #691      +/-   ##
==========================================
- Coverage   49.75%   49.60%   -0.15%     
==========================================
  Files          81       81              
  Lines        4034     4046      +12     
==========================================
  Hits         2007     2007              
- Misses       2027     2039      +12     
Flag Coverage Δ
unittests 49.60% <0.00%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@otdftr otdftr closed this Feb 8, 2024
@otdftr
Copy link
Contributor Author

otdftr commented Feb 8, 2024

this one had two bugs, creating new PR

@amotl amotl requested review from jpmens and sumnerboy12 and removed request for jpmens and sumnerboy12 February 14, 2024 23:31
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.

1 participant