Skip to content

Commit

Permalink
Update http_urllib.py
Browse files Browse the repository at this point in the history
  • Loading branch information
otdftr authored Feb 8, 2024
1 parent aac55eb commit 675fbb0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mqttwarn/services/http_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def plugin(srv, item):

if params is not None:

# shorthand [ 'param1' ] for { 'param1': '{param1}', ...}
# shorthand [ 'param1' , '@param2', '?param3' ]
# for { 'param1': '@param1', 'param2': '@param2', 'param3': '?param3' }
if isinstance(params, list):

Check warning on line 61 in mqttwarn/services/http_urllib.py

View check run for this annotation

Codecov / codecov/patch

mqttwarn/services/http_urllib.py#L61

Added line #L61 was not covered by tests
# create dict from list and replace params
newparams = {}
Expand All @@ -72,14 +73,14 @@ def plugin(srv, item):
# { 'q' : '@message' }
# Quoted field, starts with '@'. Do not use .format, instead grab
# the item's [message] and inject as parameter value.
# { 'x' : '?param' }
# new { 'x' : '?param' }
# Optional quoted field, add to query string only if it exists
# in item's data and is not empty
if params[key].startswith('@'): # "@message"
params[key] = item.get(params[key][1:], "NOP")
params[key] = item.data.get(params[key][1:], "NOP")

Check warning on line 80 in mqttwarn/services/http_urllib.py

View check run for this annotation

Codecov / codecov/patch

mqttwarn/services/http_urllib.py#L80

Added line #L80 was not covered by tests

elif params[key].startswith('?'):
myitem = item.get(params[key][1:], None)
myitem = item.data.get(params[key][1:], None)
if myitem is None:
params.pop(key,None)

Check warning on line 85 in mqttwarn/services/http_urllib.py

View check run for this annotation

Codecov / codecov/patch

mqttwarn/services/http_urllib.py#L82-L85

Added lines #L82 - L85 were not covered by tests
else:
Expand Down

0 comments on commit 675fbb0

Please sign in to comment.