MCPcopy
hub / github.com/authlib/authlib / extract_params

Function extract_params

authlib/common/urls.py:113–139  ·  view source on GitHub ↗

Extract parameters and return them as a list of 2-tuples. Will successfully extract parameters from urlencoded query strings, dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an empty list of parameters. Any other input will result in a return value of None.

(raw)

Source from the content-addressed store, hash-verified

111
112
113def extract_params(raw):
114 """Extract parameters and return them as a list of 2-tuples.
115
116 Will successfully extract parameters from urlencoded query strings,
117 dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
118 empty list of parameters. Any other input will result in a return
119 value of None.
120 """
121 if isinstance(raw, (list, tuple)):
122 try:
123 raw = dict(raw)
124 except (TypeError, ValueError):
125 return None
126
127 if isinstance(raw, dict):
128 params = []
129 for k, v in raw.items():
130 params.append((to_unicode(k), to_unicode(v)))
131 return params
132
133 if not raw:
134 return None
135
136 try:
137 return url_decode(raw)
138 except ValueError:
139 return None
140
141
142def is_valid_url(url: str, fragments_allowed=True):

Callers 4

_renderMethod · 0.90
prepareMethod · 0.90
__init__Method · 0.90

Calls 2

to_unicodeFunction · 0.85
url_decodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…