MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_qsl

Function parse_qsl

Lib/urllib/parse.py:782–861  ·  view source on GitHub ↗

Parse a query given as a string argument. Arguments: qs: percent-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that bla

(qs, keep_blank_values=False, strict_parsing=False,
              encoding='utf-8', errors='replace', max_num_fields=None, separator='&', *, _stacklevel=1)

Source from the content-addressed store, hash-verified

780
781
782def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
783 encoding='utf-8', errors='replace', max_num_fields=None, separator='&', *, _stacklevel=1):
784 """Parse a query given as a string argument.
785
786 Arguments:
787
788 qs: percent-encoded query string to be parsed
789
790 keep_blank_values: flag indicating whether blank values in
791 percent-encoded queries should be treated as blank strings.
792 A true value indicates that blanks should be retained as blank
793 strings. The default false value indicates that blank values
794 are to be ignored and treated as if they were not included.
795
796 strict_parsing: flag indicating what to do with parsing errors. If
797 false (the default), errors are silently ignored. If true,
798 errors raise a ValueError exception.
799
800 encoding and errors: specify how to decode percent-encoded sequences
801 into Unicode characters, as accepted by the bytes.decode() method.
802
803 max_num_fields: int. If set, then throws a ValueError
804 if there are more than n fields read by parse_qsl().
805
806 separator: str. The symbol to use for separating the query arguments.
807 Defaults to &.
808
809 Returns a list, as G-d intended.
810 """
811 if not separator or not isinstance(separator, (str, bytes)):
812 raise ValueError("Separator must be of type string or bytes.")
813 if isinstance(qs, str):
814 if not isinstance(separator, str):
815 separator = str(separator, 'ascii')
816 eq = '='
817 def _unquote(s):
818 return unquote_plus(s, encoding=encoding, errors=errors)
819 elif qs is None:
820 return []
821 else:
822 try:
823 # Use memoryview() to reject integers and iterables,
824 # acceptable by the bytes constructor.
825 qs = bytes(memoryview(qs))
826 except TypeError:
827 if not qs:
828 warnings.warn(f"Accepting {type(qs).__name__} objects with "
829 f"false value in urllib.parse.parse_qsl() is "
830 f"deprecated as of 3.14",
831 DeprecationWarning, stacklevel=_stacklevel + 1)
832 return []
833 raise
834 if isinstance(separator, str):
835 separator = bytes(separator, 'ascii')
836 eq = b'='
837 def _unquote(s):
838 return unquote_to_bytes(s.replace(b'+', b' '))
839

Callers 1

parse_qsFunction · 0.85

Calls 8

isinstanceFunction · 0.85
strFunction · 0.85
_unquoteFunction · 0.70
warnMethod · 0.45
countMethod · 0.45
splitMethod · 0.45
partitionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected