Lines Matching refs:safe

824     in either of the specified safe set, or the always safe set.
828 def __init__(self, safe):
829 """safe: bytes object."""
830 self.safe = _ALWAYS_SAFE.union(safe)
837 res = chr(b) if b in self.safe else '%{:02X}'.format(b)
841 def quote(string, safe='/', encoding=None, errors=None):
862 unreserved chars ("always safe") nor the additional chars set via the
863 safe arg.
865 The default for the safe arg is '/'. The character is reserved, but in
872 string and safe may be either str or bytes objects. encoding and errors
893 return quote_from_bytes(string, safe)
895 def quote_plus(string, safe='', encoding=None, errors=None):
898 they are included in safe. It also does not have safe default to '/'.
904 return quote(string, safe, encoding, errors)
905 if isinstance(safe, str):
909 string = quote(string, safe + space, encoding, errors)
914 def _byte_quoter_factory(safe):
915 return _Quoter(safe).__getitem__
917 def quote_from_bytes(bs, safe='/'):
926 if isinstance(safe, str):
927 # Normalize 'safe' by converting to bytes and removing non-ASCII chars
928 safe = safe.encode('ascii', 'ignore')
931 safe = bytes([c for c in safe if c < 128])
932 if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe):
934 quoter = _byte_quoter_factory(safe)
937 def urlencode(query, doseq=False, safe='', encoding=None, errors=None,
950 The safe, encoding, and errors parameters are passed down to the function
976 k = quote_via(k, safe)
978 k = quote_via(str(k), safe, encoding, errors)
981 v = quote_via(v, safe)
983 v = quote_via(str(v), safe, encoding, errors)
988 k = quote_via(k, safe)
990 k = quote_via(str(k), safe, encoding, errors)
993 v = quote_via(v, safe)
996 v = quote_via(v, safe, encoding, errors)
1004 v = quote_via(str(v), safe, encoding, errors)
1010 elt = quote_via(elt, safe)
1012 elt = quote_via(str(elt), safe, encoding, errors)