• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.quote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中requests.utils.quote函数的典型用法代码示例。如果您正苦于以下问题:Python quote函数的具体用法?Python quote怎么用?Python quote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: escapeUrl

    def escapeUrl(self, url):
        if isinstance(url, unicode):
            url = url.encode('utf-8') # urls have to be bytestrings
        separators = [
            '?dl=true',
            '?mkDir=true',
            '?dlDir=true',
            '?mvDir=',
            '?mv=',
            '?mode=list',
            '?mode=bin',
            '?mode=thumb&ts='
        ]
        separator = separators[0]
        for sep in separators:
            if sep in url:
                separator = sep
                break

        urlparts = url.rsplit(separator, 1)
        if(len(urlparts) == 2):
            url = quote(urlparts[0], safe=self.rootpath) + separator + urlparts[1]
        else:
            url = quote(urlparts[0], safe=self.rootpath)
        return url
开发者ID:nuth,项目名称:jottalib,代码行数:25,代码来源:JFS.py


示例2: build_dlna_play_container

 def build_dlna_play_container(udn, server_type, path):
     s = "dlna-playcontainer://" + quote(udn)
     s += "?"
     s += 'sid=' + quote(server_type)
     s += '&cid=' + quote(path)
     s += '&md=0'
     return s
开发者ID:scjurgen,项目名称:pyfeld,代码行数:7,代码来源:rfcmd.py


示例3: append_url_with_template_parameters

    def append_url_with_template_parameters(url,
                                            parameters):
        """Replaces template parameters in the given url.

        Args:
            url (str): The query url string to replace the template parameters.
            parameters (dict): The parameters to replace in the url.

        Returns:
            str: URL with replaced parameters.

        """
        # Parameter validation
        if url is None:
            raise ValueError("URL is None.")
        if parameters is None:
            return url

        # Iterate and replace parameters
        for key in parameters:
            element = parameters[key]
            replace_value = ""

            # Load parameter value
            if element is None:
                replace_value = ""
            elif isinstance(element, list):
                replace_value = "/".join(quote(str(x), safe='') for x in element)
            else:
                replace_value = quote(str(element), safe='')

            url = url.replace('{{{0}}}'.format(key), str(replace_value))

        return url
开发者ID:pepipost,项目名称:pepipost-sdk-python,代码行数:34,代码来源:api_helper.py


示例4: get_branch_request

def get_branch_request(base_url, project, branch, auth=None):
    if not project or not branch:
        return None
    project = quote(str(project), '')
    branch = quote(str(branch), '')
    endpoint = ('/api/v3/projects/{project}/repository/branches/{branch}'
                .format(project=project, branch=branch))
    return get_request('get', base_url, endpoint, auth=auth)
开发者ID:Phantuman,项目名称:igmonplugins,代码行数:8,代码来源:gitlab_unprotected_branches.py


示例5: deleteGroup

	def deleteGroup(self, groupName, recursive=False):
		''' Removes a given group.
		Args: 
		   groupName : name of the group
		   recursive : enforce recursive removal 
		Returns:
		   nothing
		'''
		self.logger.debug('deleteGroup ' + groupName)
		if recursive :
			self._delete('group/' + quote(groupName,''), params={'recursive':'on'})
		else :
			self._delete('group/' + quote(groupName,''))
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:13,代码来源:unity_api.py


示例6: url

    def url(self, resource_name, resource_id=None, sub_resource=None,
            sub_resource_id=None, **kwargs):
        '''\
        Build a request url from path fragments and query parameters

        :returns: str\
        '''
        path = (self.base_url, resource_name, resource_id,
                sub_resource, sub_resource_id)
        url = '/'.join(p for p in path if p) + '.json'
        if kwargs:
            url += '?' + '&'.join(quote(str(k)) + '=' + quote(str(v))
                                  for k, v in iteritems(kwargs))
        return url
开发者ID:OnePageCRM,项目名称:python_client,代码行数:14,代码来源:onepagecrm.py


示例7: __init__

    def __init__(self, query, per_page=10, start_page=1, lazy=True, **kwargs):
        """
        Args:
            query(str):         The search query to execute.
            per_page(int):      The number of results to retrieve per page.
            start_page(int):    The starting page for queries.
            lazy(bool):         Don't execute the query until results are requested. Defaults to True.
            **kwargs:           Arbitrary keyword arguments, refer to the documentation for more information.

        Raises:
            ValueError: Raised if the supplied per_page argument is less than 1 or greater than 100
        """
        self._log = logging.getLogger('poogle')

        self._query        = query
        self._search_url   = self.SEARCH_URL + quote(query)

        if (per_page < 1) or (per_page > 100):
            raise ValueError('per_page must contain be an integer between 1 and 100')
        self._per_page     = per_page

        self._lazy         = lazy
        self._query_count  = 0
        self.total_results = 0

        self._results      = []
        self._current_page = start_page - 1
        self.last          = None

        self.strict = kwargs.get('strict', False)

        if not self._lazy:
            self.next_page()
开发者ID:FujiMakoto,项目名称:Poogle,代码行数:33,代码来源:__init__.py


示例8: create_asset

    def create_asset(self, name, label, content_type, download_url,
                     upload_url):
        """Create and upload a new asset for a mirror repository.

        The assets upload method is not supported by PyGitHub. This method
        downloads an asset from the original repository and makes a new asset
        upload in the mirrored repository by querying against the GitHub API
        directly.

        """
        if label is None:
            upload_url = upload_url.replace("{?name,label}", "") + "?name={}"
            upload_url = upload_url.format(name)
        else:
            upload_url = upload_url.replace("{?name,label}", "") +\
                "?name={}&label={}"
            upload_url = upload_url.format(name, quote(label))

        headers = {"Content-type": content_type,
                   "Authorization": "token {}".format(self.token)}

        data = urllib2.urlopen(download_url).read()

        res = requests.post(url=upload_url,
                            data=data,
                            headers=headers,
                            verify=False)
开发者ID:Fiware,项目名称:tools.Webhook,代码行数:27,代码来源:githubmirrorutils.py


示例9: get_fetch_plugin_license_request

def get_fetch_plugin_license_request(base_url, plugin_key, auth=None):
    if not plugin_key:
        return None
    plugin_key = quote(str(plugin_key), '')
    endpoint = ('/rest/plugins/1.0/{plugin_key}/license'
                .format(plugin_key=plugin_key))
    return grequests.get(base_url + endpoint, auth=auth)
开发者ID:lacunoc,项目名称:igmonplugins,代码行数:7,代码来源:atlassian_expiring_licenses.py


示例10: escape

def escape(url):
    """
prototype::
    arg = str: url ;
          the link that must be escaped

    return = str ;
             the escaped ¨http version of the url


This function escapes the url using the ¨http ¨ascii convention. Here is an
example of use.

pyterm::
    >>> from mistool.url_use import escape
    >>> print(escape("http://www.vivaespaña.com/camión/"))
    http://www.vivaespa%C3%B1a.com/cami%C3%B3n/


info::
    The function uses the global string ``CHAR_TO_KEEP = "/:#&?="`` which
    contains the characters that mustn't be escaped.
    """
    return quote(
        string = url,
        safe   = CHAR_TO_KEEP
    )
开发者ID:bc-python-tools,项目名称:mistool,代码行数:27,代码来源:url_use.py


示例11: alert_hipchat

def alert_hipchat(alert, metric, second_order_resolution_seconds):

    # SECOND_ORDER_RESOLUTION_SECONDS to hours so that Mirage surfaces the
    # relevant timeseries data in the graph
    second_order_resolution_in_hours = int(second_order_resolution_seconds) / 3600

    if settings.HIPCHAT_ENABLED:
        sender = settings.HIPCHAT_OPTS['sender']
        import hipchat
        hipster = hipchat.HipChat(token=settings.HIPCHAT_OPTS['auth_token'])
        rooms = settings.HIPCHAT_OPTS['rooms'][alert[0]]

        unencoded_graph_title = 'Skyline Mirage - ALERT at %s hours - anomalous data point - %s' % (
            second_order_resolution_in_hours, metric[0])
        graph_title_string = quote(unencoded_graph_title, safe='')
        graph_title = '&title=%s' % graph_title_string

        if settings.GRAPHITE_PORT != '':
            link = '%s://%s:%s/render/?from=-%shour&target=cactiStyle(%s)%s%s&colorList=orange' % (settings.GRAPHITE_PROTOCOL, settings.GRAPHITE_HOST, settings.GRAPHITE_PORT, second_order_resolution_in_hours, metric[1], settings.GRAPHITE_GRAPH_SETTINGS, graph_title)
        else:
            link = '%s://%s/render/?from=-%shour&target=cactiStyle(%s)%s%s&colorList=orange' % (settings.GRAPHITE_PROTOCOL, settings.GRAPHITE_HOST, second_order_resolution_in_hours, metric[1], settings.GRAPHITE_GRAPH_SETTINGS, graph_title)
        embed_graph = "<a href='" + link + "'><img height='308' src='" + link + "'>" + metric[1] + "</a>"

        for room in rooms:
            hipster.method('rooms/message', method='POST', parameters={'room_id': room, 'from': 'skyline', 'color': settings.HIPCHAT_OPTS['color'], 'message': '%s - Mirage - Anomalous metric: %s (value: %s) at %s hours %s' % (sender, metric[1], metric[0], second_order_resolution_in_hours, embed_graph)})
    else:
        hipchat_not_enabled = True
开发者ID:blak3r2,项目名称:skyline,代码行数:27,代码来源:mirage_alerters.py


示例12: lookup_in_cdx

def lookup_in_cdx(qurl):
    """
    Checks if a resource is in the CDX index.
    :return:
    """
    query = "%s?q=type:urlquery+url:%s" % (systems().cdxserver, quote(qurl))
    r = requests.get(query)
    print(r.url)
    app.logger.debug("Availability response: %d" % r.status_code)
    print(r.status_code, r.text)
    # Is it known, with a matching timestamp?
    if r.status_code == 200:
        try:
            dom = xml.dom.minidom.parseString(r.text)
            for result in dom.getElementsByTagName('result'):
                file = result.getElementsByTagName('file')[0].firstChild.nodeValue
                compressedoffset = result.getElementsByTagName('compressedoffset')[0].firstChild.nodeValue
                return file, compressedoffset
        except Exception as e:
            app.logger.error("Lookup failed for %s!" % qurl)
            app.logger.exception(e)
        #for de in dom.getElementsByTagName('capturedate'):
        #    if de.firstChild.nodeValue == self.ts:
        #        # Excellent, it's been found:
        #        return
    return None, None
开发者ID:ukwa,项目名称:python-shepherd,代码行数:26,代码来源:dashboard.py


示例13: get_fetch_plugin_versions_request

def get_fetch_plugin_versions_request(base_url, plugin_key, params={}):
    if not plugin_key:
        return
    plugin_key = quote(str(plugin_key), '')
    endpoint = ('/rest/2/addons/{plugin_key}/versions'
                .format(plugin_key=plugin_key))
    return grequests.get(base_url + endpoint, params=params)
开发者ID:Phantuman,项目名称:igmonplugins,代码行数:7,代码来源:atlassian_plugin_updates.py


示例14: read_queries_from_file

 def read_queries_from_file(self):
     """
     read queries from file and qute it as urlencoded
     """
     with open(self.queries_file, 'r') as f:
         for line in f:
             self.queries.append(quote(line))
开发者ID:schituku,项目名称:svt,代码行数:7,代码来源:prometheus-loader.py


示例15: get_context_data

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['project'] = self.project

        build = self.get_object()
        if build.error != BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(build_id=build.pk):
            # Do not suggest to open an issue if the error is not generic
            return context

        scheme = (
            'https://github.com/rtfd/readthedocs.org/issues/new'
            '?title={title}{build_id}'
            '&body={body}'
        )

        # TODO: we could use ``.github/ISSUE_TEMPLATE.md`` here, but we would
        # need to add some variables to it which could impact in the UX when
        # filling an issue from the web
        body = """
        ## Details:

        * Project URL: https://readthedocs.org/projects/{project_slug}/
        * Build URL(if applicable): https://readthedocs.org{build_path}
        * Read the Docs username(if applicable): {username}

        ## Expected Result

        *A description of what you wanted to happen*

        ## Actual Result

        *A description of what actually happened*""".format(
            project_slug=self.project,
            build_path=self.request.path,
            username=self.request.user,
        )

        scheme_dict = {
            'title': quote('Build error with build id #'),
            'build_id': context['build'].id,
            'body': quote(textwrap.dedent(body)),
        }

        issue_url = scheme.format(**scheme_dict)
        issue_url = urlparse(issue_url).geturl()
        context['issue_url'] = issue_url
        return context
开发者ID:chrisjsewell,项目名称:readthedocs.org,代码行数:47,代码来源:views.py


示例16: login

def login():
    """
    Initiate login attempt
    :return: Redirects to GitHub for login
    """
    return redirect("https://github.com/login/oauth/authorize?client_id=" +
                    GITHUB_CLIENT_ID + "&redirect_uri=" +
                    quote(OAUTH_REDIRECT_URI), code=302)
开发者ID:rahimnathwani,项目名称:fullstack-nanodegree-vm,代码行数:8,代码来源:application.py


示例17: getGroup

	def getGroup(self, groupName='/'):
		''' Returns all members and subgroups of a given group.
		Args: 
		   groupName : name of the group, default is root
		Returns:
		   all members and subgroups of a given group
		'''
		self.logger.debug('getGroup ' + groupName)
		return self._get('group/' + quote(groupName,''))
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:9,代码来源:unity_api.py


示例18: createGroup

	def createGroup(self, groupName):	
		''' Creates a new group. The created group will be empty.
		Args: 
		   groupName : name of the group
		Returns:
		   nothing
		'''
		self.logger.debug('createGroup ' + groupName)
		self._post('group/' + quote(groupName,''))
开发者ID:EUDAT-B2SAFE,项目名称:B2SAFE-core,代码行数:9,代码来源:unity_api.py


示例19: document_available

def document_available(wayback_url, url, ts):
    """

    Queries Wayback to see if the content is there yet.

    e.g.
    http://192.168.99.100:8080/wayback/xmlquery.jsp?type=urlquery&url=https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/497662/accidents-involving-illegal-alcohol-levels-2014.pdf

    <wayback>
    <request>
        <startdate>19960101000000</startdate>
        <resultstype>resultstypecapture</resultstype>
        <type>urlquery</type>
        <enddate>20160204115837</enddate>
        <firstreturned>0</firstreturned>
        <url>uk,gov)/government/uploads/system/uploads/attachment_data/file/497662/accidents-involving-illegal-alcohol-levels-2014.pdf
</url>
        <resultsrequested>10000</resultsrequested>
        <resultstype>resultstypecapture</resultstype>
    </request>
    <results>
        <result>
            <compressedoffset>2563</compressedoffset>
            <mimetype>application/pdf</mimetype>
            <redirecturl>-</redirecturl>
            <file>BL-20160204113809800-00000-33~d39c9051c787~8443.warc.gz
</file>
            <urlkey>uk,gov)/government/uploads/system/uploads/attachment_data/file/497662/accidents-involving-illegal-alcohol-levels-2014.pdf
</urlkey>
            <digest>JK2AKXS4YFVNOTPS7Q6H2Q42WQ3PNXZK</digest>
            <httpresponsecode>200</httpresponsecode>
            <robotflags>-</robotflags>
            <url>https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/497662/accidents-involving-illegal-alcohol-levels-2014.pdf
</url>
            <capturedate>20160204113813</capturedate>
        </result>
    </results>
</wayback>

    """
    try:
        wburl = '%s/xmlquery.jsp?type=urlquery&url=%s' % (wayback_url, quote(url))
        logger.debug("Checking %s" % wburl);
        r = requests.get(wburl)
        logger.debug("Response: %d" % r.status_code)
        # Is it known, with a matching timestamp?
        if r.status_code == 200:
            dom = xml.dom.minidom.parseString(r.text)
            for de in dom.getElementsByTagName('capturedate'):
                if de.firstChild.nodeValue == ts:
                    # Excellent, it's been found:
                    return True
    except Exception as e:
        logger.error( "%s [%s %s]" % ( str( e ), url, ts ) )
        logger.exception(e)
    # Otherwise:
    return False
开发者ID:ukwa,项目名称:python-shepherd,代码行数:57,代码来源:to_w3act.py


示例20: test_prepare_http_request_correct

 def test_prepare_http_request_correct(self):
     """
     Tests that prepare_http_request returns a proper HTTP request if all the mandatory
     parameters are passed in as expected.
     """
     for kw in ("fluent python", "hello", "@#$%&&&&&", "[email protected]#@#"):
         request = prepare_http_request(keyword=kw)
         expected_request = "https://www.googleapis.com/books/v1/volumes?q=%s" % (quote(kw))
         self.assertEqual(request, expected_request)
开发者ID:jaschac,项目名称:celery-for-mere-mortals,代码行数:9,代码来源:test_http.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.super_len函数代码示例发布时间:2022-05-26
下一篇:
Python utils.is_valid_cidr函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap