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

Function quote_plus

Lib/urllib/parse.py:954–969  ·  view source on GitHub ↗

Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'.

(string, safe='', encoding=None, errors=None)

Source from the content-addressed store, hash-verified

952 return quote_from_bytes(string, safe)
953
954def quote_plus(string, safe='', encoding=None, errors=None):
955 """Like quote(), but also replace ' ' with '+', as required for quoting
956 HTML form values. Plus signs in the original string are escaped unless
957 they are included in safe. It also does not have safe default to '/'.
958 """
959 # Check if ' ' in string, where string may either be a str or bytes. If
960 # there are no spaces, the regular quote will produce the right answer.
961 if ((isinstance(string, str) and ' ' not in string) or
962 (isinstance(string, bytes) and b' ' not in string)):
963 return quote(string, safe, encoding, errors)
964 if isinstance(safe, str):
965 space = ' '
966 else:
967 space = b' '
968 string = quote(string, safe + space, encoding, errors)
969 return string.replace(' ', '+')
970
971# Expectation: A typical program is unlikely to create more than 5 of these.
972@functools.lru_cache

Callers

nothing calls this directly

Calls 3

isinstanceFunction · 0.85
quoteFunction · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected