当前位置: 首页>>代码示例>>Python>>正文


Python parse.quote_plus方法代码示例

本文整理汇总了Python中six.moves.urllib.parse.quote_plus方法的典型用法代码示例。如果您正苦于以下问题:Python parse.quote_plus方法的具体用法?Python parse.quote_plus怎么用?Python parse.quote_plus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.urllib.parse的用法示例。


在下文中一共展示了parse.quote_plus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enurlquote

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def enurlquote(v, plus=False):
    """
    Percent encode a string for use in an URL.

    Args:
        v(str): The value to percent encode.
        plus(bool): Use a plus symbol for spaces, otherwise use %20.

    Returns:
        str: The percent encoded string.

    Example:
        >>> from pwny import *
        >>> enurlquote('Foo Bar/Baz', True)
        'Foo+Bar/Baz
    """
    return quote_plus(v) if plus else quote(v) 
开发者ID:edibledinos,项目名称:pwnypack,代码行数:19,代码来源:codec.py

示例2: check_query_length

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def check_query_length(query):
        """Determine whether a query to the OpenSearch API is too long.

        The length of a query string is limited to approximately 3938 characters but
        any special characters (that is, not alphanumeric or -_.*) will take up more space.

        Parameters
        ----------
        query : str
            The query string

        Returns
        -------
        float
            Ratio of the query length to the maximum length
        """
        # The server uses the Java's URLEncoder implementation internally, which we are replicating here
        effective_length = len(quote_plus(query, safe="-_.*").replace("~", "%7E"))

        return effective_length / 3938 
开发者ID:sentinelsat,项目名称:sentinelsat,代码行数:22,代码来源:sentinel.py

示例3: unzip

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def unzip(path, dest, folder=None):

    ''' Unzip file. zipfile module seems to fail on android with badziperror.
    '''
    path = quote_plus(path)
    root = "zip://" + path + '/'

    if folder:

        xbmcvfs.mkdir(os.path.join(dest, folder))
        dest = os.path.join(dest, folder)
        root = get_zip_directory(root, folder)

    dirs, files = xbmcvfs.listdir(root)

    if dirs:
        unzip_recursive(root, dirs, dest)

    for file in files:
        unzip_file(os.path.join(root, file), os.path.join(dest, file))

    LOG.info("Unzipped %s", path) 
开发者ID:jellyfin,项目名称:jellyfin-kodi,代码行数:24,代码来源:utils.py

示例4: check_address

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def check_address(self, email):
        """
        Check if an email address is registered for export data
        requests.

        Parameters
        ----------
        email : string
            Email address to be verified.

        Returns
        -------
        result : dict
            Dictionary containing 'status' and 'msg'. Some status
            codes are:
                2: Email address is valid and registered
                4: Email address has neither been validated nor
                   registered
               -2: Not a valid email address
        """
        query = '?' + urlencode({
            'address': quote_plus(email), 'checkonly': '1'})
        req = self._json_request(self._server.url_check_address + query)
        return req.data 
开发者ID:sunpy,项目名称:drms,代码行数:26,代码来源:json.py

示例5: auth_strings

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def auth_strings(draw, auth=auth_list()):
    auth_section = draw(auth)
    if auth_section and len(auth_section) == 2:
        user, password = auth_section
        if user and password:
            result = "{0}:{1}".format(
                urllib_parse.quote_plus(user.encode()),
                urllib_parse.quote_plus(password.encode()),
            )
        elif user and not password:
            result = urllib_parse.quote_plus(user.encode())
        elif password and not user:
            result = urllib_parse.quote_plus(password.encode())
        else:
            result = ""
    elif auth_section and len(auth_section) == 1:
        result = "{0}".format(urllib_parse.quote_plus(next(iter(auth_section)).encode()))
    else:
        result = ""
    return result 
开发者ID:sarugaku,项目名称:requirementslib,代码行数:22,代码来源:strategies.py

示例6: get_tg_vars

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def get_tg_vars(context):
    import tg
    from allura.lib import helpers as h
    from six.moves.urllib.parse import quote, quote_plus
    context.setdefault('g', tg.app_globals)
    context.setdefault('c', tg.tmpl_context)
    context.setdefault('h', h)
    context.setdefault('request', tg.request)
    context.setdefault('response', tg.response)
    context.setdefault('url', tg.url)
    context.setdefault('tg', dict(
        config=tg.config,
        flash_obj=tg.flash,
        quote=quote,
        quote_plus=quote_plus,
        url=tg.url)) 
开发者ID:apache,项目名称:allura,代码行数:18,代码来源:middleware.py

示例7: test_get_correct_authorization_url

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def test_get_correct_authorization_url(redirect_url):
    # pylint:disable=redefined-outer-name
    fake_client_id = 'fake_client_id'
    fake_client_secret = 'fake_client_secret'
    oauth2 = OAuth2(
        client_id=fake_client_id,
        client_secret=fake_client_secret,
    )
    auth_url, csrf_token = oauth2.get_authorization_url(redirect_url=redirect_url)
    expected_auth_url_format = '{0}?state={1}&response_type=code&client_id={2}'
    if redirect_url:
        expected_auth_url_format += '&redirect_uri={3}'
    assert auth_url == expected_auth_url_format.format(
        API.OAUTH2_AUTHORIZE_URL,
        csrf_token,
        fake_client_id,
        urlparse.quote_plus((redirect_url or '').encode('utf-8')),
    )
    assert re.match('^box_csrf_token_[A-Za-z0-9]{16}$', csrf_token) 
开发者ID:box,项目名称:box-python-sdk,代码行数:21,代码来源:test_oauth2.py

示例8: _build_params_query

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def _build_params_query(self, params=None):
        flag_params = []
        keyval_params = {}
        for key, value in params.items():
            if value is None:
                flag_params.append(key)
            else:
                keyval_params[key] = value

        flags_encoded = utils.safe_encode_list(flag_params) \
            if flag_params else ""
        keyval_encoded = utils.safe_encode_dict(keyval_params) \
            if keyval_params else ""

        query = ""
        for flag in flags_encoded:
            query = query + urlparse.quote_plus(flag) + '&'
        query = query + urlparse.urlencode(keyval_encoded, doseq=1)
        return query.strip('&') 
开发者ID:openstack,项目名称:python-tackerclient,代码行数:21,代码来源:client.py

示例9: add_filter

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def add_filter(self, expr):
        expr = quote_plus(expr)
        self._filters.append(expr) 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:5,代码来源:request.py

示例10: _to_google_maps_url

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def _to_google_maps_url(self, params):
        url_base = "https://www.google.com/maps/search/?api=1&query="
        url_ending = params[0]
        for i in range(1, len(params)):
            url_ending = url_ending + "," + params[i]

        final_url = url_base + quote_plus(url_ending)
        return final_url 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:10,代码来源:sdo.py

示例11: _to_bing_maps_url

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def _to_bing_maps_url(self, params):
        url_base = "https://bing.com/maps/default.aspx?where1="
        url_ending = params[0]
        for i in range(1, len(params)):
            url_ending = url_ending + "," + params[i]

        final_url = url_base + quote_plus(url_ending) + "&lvl=16"   # level 16 zoom so long/lat searches shown more clearly
        return final_url 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:10,代码来源:sdo.py

示例12: test_relay_state

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def test_relay_state():
    target = build_authentication_request_simple()
    state = 'http://localhost:8080/'
    uri, _ = client.send('http://localhost', target.serialize(), state)

    relay_state_part = 'RelayState=%s' % quote_plus(state)
    assert relay_state_part in uri 
开发者ID:mehcode,项目名称:python-saml,代码行数:9,代码来源:test_client.py

示例13: url_quoted

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def url_quoted(self):
        return quote_plus(
            self.value.replace('\r\n', ' ').replace('\r', ' ').replace('\n', ' ')
        ) 
开发者ID:phildini,项目名称:logtacts,代码行数:6,代码来源:models.py

示例14: _get_youtube_query

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def _get_youtube_query(metadata):
    """Generates a query string to search youtube for this song

    See https://developers.google.com/youtube/player_parameters#Manual_IFrame_Embeds
    for more info.
    """
    if not ('artist' in metadata and 'title' in metadata):
        return None
    else:
        return "{artist}+{title}".format(
            artist=quote_plus(metadata['artist'].encode("UTF-8")),
            title=quote_plus(metadata['title'].encode("UTF-8")),
        ) 
开发者ID:metabrainz,项目名称:acousticbrainz-server,代码行数:15,代码来源:data.py

示例15: websocket_call

# 需要导入模块: from six.moves.urllib import parse [as 别名]
# 或者: from six.moves.urllib.parse import quote_plus [as 别名]
def websocket_call(configuration, url, query_params, _request_timeout,
                   _preload_content, headers):
    """An internal function to be called in api-client when a websocket
    connection is required."""

    # Extract the command from the list of tuples
    commands = None
    for key, value in query_params:
        if key == 'command':
            commands = value
            break

    # drop command from query_params as we will be processing it separately
    query_params = [(key, value) for key, value in query_params if
                    key != 'command']

    # if we still have query params then encode them
    if query_params:
        url += '?' + urlencode(query_params)

    # tack on the actual command to execute at the end
    if isinstance(commands, list):
        for command in commands:
            url += "&command=%s&" % quote_plus(command)
    elif commands is not None:
        url += '&command=' + quote_plus(commands)

    try:
        client = WSClient(configuration, get_websocket_url(url), headers)
        if not _preload_content:
            return client
        client.run_forever(timeout=_request_timeout)
        return WSResponse('%s' % ''.join(client.read_all()))
    except (Exception, KeyboardInterrupt, SystemExit) as e:
        raise ApiException(status=0, reason=str(e)) 
开发者ID:aws-samples,项目名称:aws-kube-codesuite,代码行数:37,代码来源:ws_client.py


注:本文中的six.moves.urllib.parse.quote_plus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。