requests.utils.quote - python examples

Here are the examples of the python api requests.utils.quote taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

52 Examples 7

5 View Complete Implementation : _googleplayapi.py
Copyright GNU General Public License v3.0
Author : tongtzeho
    def list(self, cat, ctr=None, nb_results=None, offset=None):
        """List apps.

        If ctr (subcategory ID) is None, returns a list of valid subcategories.

        If ctr is provided, list apps within this subcategory."""
        path = "list?c=3&cat=%s" % requests.utils.quote(cat)
        if (ctr != None):
            path += "&ctr=%s" % requests.utils.quote(ctr)
        if (nb_results != None):
            path += "&n=%s" % requests.utils.quote(nb_results)
        if (offset != None):
            path += "&o=%s" % requests.utils.quote(offset)
        message = self.executeRequestApi2(path)
        return message.payload.listResponse

3 View Complete Implementation : test_edgeauth.py
Copyright Apache License 2.0
Author : akamai
    def test_url_escape_on__ignoreQuery_no(self):
        query_path = "/q_escape"
        cookie_path = "/c_escape"
        header_path = "/h_escape"

        self._test_case_set(query_path, query_path, 
                            cookie_path, cookie_path, 
                            header_path, header_path, 
                            escape_early=True, is_url=True)

        query_path = "/q_escape?" + quote("안녕=세상") 
        cookie_path = "/c_escape?" + quote("hello=world")
        header_path = "/h_escape?" + quote("1=2")
        self._test_case_set(query_path, query_path, 
                            cookie_path, cookie_path, 
                            header_path, header_path, 
                            escape_early=True, is_url=True)

3 View Complete Implementation : test_edgeauth.py
Copyright Apache License 2.0
Author : akamai
    def test_url_escape_off__ignoreQuery_no(self):
        query_path = "/q"
        cookie_path = "/c"
        header_path = "/h"
        self._test_case_set(query_path, query_path, 
                            cookie_path, cookie_path, 
                            header_path, header_path, 
                            escape_early=False, is_url=True)

        query_path = "/q" + quote("1=2")
        cookie_path = "/c" + quote("안녕=세상")
        header_path = "/h" + quote("hello=world")
        self._test_case_set(query_path, query_path, 
                            cookie_path, cookie_path, 
                            header_path, header_path, 
                            escape_early=False, is_url=True)

3 View Complete Implementation : events.py
Copyright Apache License 2.0
Author : awslabs
    def url_encode(self, value):
        """
        url encodes the value pasted in

        Parameters
        ----------
        value: string
            the value that needs to be encoded in the json
        Returns
        -------
        string: the url encoded value
        """

        return quote(value)

3 View Complete Implementation : scholarly.py
Copyright GNU General Public License v3.0
Author : chintu619
    def get_citedby(self):
        """Searches GScholar for other articles that cite this Publication and
        returns a Publication generator.
        """
        if not hasattr(self, 'id_scholarcitedby'):
            self.fill()
        if hasattr(self, 'id_scholarcitedby'):
            url = _SCHOLARPUB.format(requests.utils.quote(self.id_scholarcitedby))
            soup = _get_soup(_HOST+url)
            return _search_scholar_soup(soup)
        else:
            return []

3 View Complete Implementation : twitter.py
Copyright Apache License 2.0
Author : fossasia
    def search(self, query, num_results, qtype=''):
        """ Makes a GET request to Loklak API and returns the URLs
        Returns: urls (list)
                [[satle1,url1], [satle2, url2],..]
        """
        encodedQuery = requests.utils.quote(query, safe='')
        url = self.loklakURL+encodedQuery

        responses = requests.get(url).json()

        tweets = []
        for response in responses['statuses']:
            tweets.append({'link': response['link'], 'text': response['text']})

        print('Twitter parsed: ' + str(tweets))

        return tweets[:num_results]

3 View Complete Implementation : decorators.py
Copyright MIT License
Author : LINKIWI
def require_login_frontend(only_if=True):
    """
    Same logic as the API require_login, but this decorator is intended for use for frontend interfaces.
    It returns a redirect to the login page, along with a post-login redirect_url as a GET parameter.

    :param only_if: Optionally specify a boolean condition that needs to be true for the frontend login to be required.
                    This is semantically equivalent to "require login for this view endpoint only if <condition>,
                    otherwise, no login is required"
    """
    def decorator(func):
        @wraps(func)
        def decorated_view(*args, **kwargs):
            if not current_user.is_authenticated and only_if:
                return redirect(UserLoginInterfaceURI.uri(redirect_url=quote(request.url, safe='')))
            return func(*args, **kwargs)
        return decorated_view
    return decorator

3 View Complete Implementation : _clashogram.py
Copyright MIT License
Author : mehdisadeghi
    def send(self, msg, silent=False):
        endpoint = "https://api.telegram.org/bot{bot_token}/sendMessage?"\
                   "parse_mode={mode}&chat_id=@{channel_name}&text={text}"\
                   "&disable_notification={silent}"\
                   .format(bot_token=self.bot_token,
                           mode='HTML',
                           channel_name=self.channel_name,
                           text=requests.utils.quote(msg),
                           silent=silent)
        requests.post(endpoint)

3 View Complete Implementation : googleplay.py
Copyright GNU General Public License v3.0
Author : NoMore201
    def searchSuggest(self, query):
        params = {"c": "3",
                  "q": requests.utils.quote(query),
                  "ssis": "120",
                  "sst": "2"}
        data = self.executeRequestApi2(SEARCH_SUGGEST_URL, params=params)
        entryIterator = data.payload.searchSuggestResponse.entry
        return list(map(utils.parseProtobufObj, entryIterator))

3 View Complete Implementation : googleplay.py
Copyright GNU General Public License v3.0
Author : NoMore201
    def details(self, packageName):
        """Get app details from a package name.

        packageName is the app unique ID (usually starting with 'com.')."""
        path = DETAILS_URL + "?doc={}".format(requests.utils.quote(packageName))
        data = self.executeRequestApi2(path)
        return utils.parseProtobufObj(data.payload.detailsResponse.docV2)