Convert a mapping object or a sequence of two-element tuples. Wrapper to Python's `urlencode` while remaining compatible with both Python 2 & 3 since the reference to this function changed between versions. The resulting string is a series of key=value pairs separat
(query, doseq=False, safe="", encoding=None, errors=None)
| 677 | |
| 678 | @staticmethod |
| 679 | def urlencode(query, doseq=False, safe="", encoding=None, errors=None): |
| 680 | """Convert a mapping object or a sequence of two-element tuples. |
| 681 | |
| 682 | Wrapper to Python's `urlencode` while remaining compatible with both |
| 683 | Python 2 & 3 since the reference to this function changed between |
| 684 | versions. |
| 685 | |
| 686 | The resulting string is a series of key=value pairs separated by '&' |
| 687 | characters, where both key and value are quoted using the quote() |
| 688 | function. |
| 689 | |
| 690 | Note: If the dictionary entry contains an entry that is set to None |
| 691 | it is not included in the final result set. If you want to |
| 692 | pass in an empty variable, set it to an empty string. |
| 693 | |
| 694 | Args: |
| 695 | query (str): The dictionary to encode |
| 696 | doseq (:obj:`bool`, optional): Handle sequences |
| 697 | safe (:obj:`str`): non-ascii characters and URI specific ones that |
| 698 | you do not wish to escape (if detected). Setting this string |
| 699 | to an empty one causes everything to be escaped. |
| 700 | encoding (:obj:`str`, optional): encoding type |
| 701 | errors (:obj:`str`, errors): how to handle invalid character found |
| 702 | in encoded string (defined by encoding) |
| 703 | |
| 704 | Returns: |
| 705 | str: The escaped parameters returned as a string |
| 706 | """ |
| 707 | return urlencode( |
| 708 | query, doseq=doseq, safe=safe, encoding=encoding, errors=errors |
| 709 | ) |
| 710 | |
| 711 | @staticmethod |
| 712 | def split_path(path, unquote=True): |