Skip to content

Commit

Permalink
Merge cced99f into f71681a
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech authored Sep 13, 2019
2 parents f71681a + cced99f commit f744224
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 88 deletions.
40 changes: 0 additions & 40 deletions flask_rest_api/arguments.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Arguments parsing"""
from copy import deepcopy
from functools import wraps
import re

from webargs import core
from webargs.flaskparser import FlaskParser


Expand Down Expand Up @@ -78,41 +76,3 @@ def wrapper(*f_args, **f_kwargs):
schema, locations=[location], **kwargs)(wrapper)

return decorator


# Copied from webargs advanced usage custom parsers
# https://webargs.readthedocs.io/en/latest/advanced.html#custom-parsers
class NestedQueryArgsParser(FlaskParser):
"""Parses nested query args
This parser handles nested query args. It expects nested levels
delimited by a period and then deserializes the query args into a
nested dict.
For example, the URL query params `?name.first=John&name.last=Boone`
will yield the following dict:
{
'name': {
'first': 'John',
'last': 'Boone',
}
}
"""
def parse_querystring(self, req, name, field):
return core.get_value(_structure_dict(req.args), name, field)


def _structure_dict(dict_):
def structure_dict_pair(r, key, value):
match = re.match(r'(\w+)\.(.*)', key)
if match:
if r.get(match.group(1)) is None:
r[match.group(1)] = {}
structure_dict_pair(r[match.group(1)], match.group(2), value)
else:
r[key] = value
ret = {}
for key, val in dict_.items():
structure_dict_pair(ret, key, val)
return ret
48 changes: 0 additions & 48 deletions tests/test_arguments.py

This file was deleted.

0 comments on commit f744224

Please sign in to comment.