MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _parse_options

Function _parse_options

pymongo/uri_parser_shared.py:231–250  ·  view source on GitHub ↗

Helper method for split_options which creates the options dict. Also handles the creation of a list for the URI tag_sets/ readpreferencetags portion, and the use of a unicode options string.

(opts: str, delim: Optional[str])

Source from the content-addressed store, hash-verified

229
230
231def _parse_options(opts: str, delim: Optional[str]) -> _CaseInsensitiveDictionary:
232 """Helper method for split_options which creates the options dict.
233 Also handles the creation of a list for the URI tag_sets/
234 readpreferencetags portion, and the use of a unicode options string.
235 """
236 options = _CaseInsensitiveDictionary()
237 for uriopt in opts.split(delim):
238 key, value = uriopt.split("=")
239 if key.lower() == "readpreferencetags":
240 options.setdefault(key, []).append(value)
241 else:
242 if key in options:
243 warnings.warn(f"Duplicate URI option '{key}'.", stacklevel=2)
244 if key.lower() == "authmechanismproperties":
245 val = value
246 else:
247 val = unquote_plus(value)
248 options[key] = val
249
250 return options
251
252
253def _handle_security_options(options: _CaseInsensitiveDictionary) -> _CaseInsensitiveDictionary:

Callers 1

split_optionsFunction · 0.85

Calls 2

setdefaultMethod · 0.45

Tested by

no test coverage detected