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


Python Broker.sanitize_bool方法代码示例

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


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

示例1: submit

# 需要导入模块: from request import Broker [as 别名]
# 或者: from request.Broker import sanitize_bool [as 别名]
    def submit(cls,
               *args,
               **kwargs):
        """
        Submit batch request. All non-named args are considered to be
        dictionaries containing the following:

            type: The request type (GET, POST, etc.).
            url: The full or relative URL for the API call.
            body: If the type is POST this is the body that will be used.

        If you use "method" instead of "type" and/or "relative_urL" instead of
        "url" (which is accurate to the Graph API) we will use them
        appropriately.

        If you pass a named argument, we will consider the name as the name you
        wish to include in that specific request. This is useful for referencing
        a request in another request in the Batch (see FB documentation).

        The following named args are considered to be the options below.

        :param include_headers: Include headers in response.
        :type include_headers: bool
        :param omit_response: Omit response on success.
        :type omit_response: bool
        :param retries: Number of retries before stopping.
        :type retries: int
        :param headers: header info for requests.
        :type headers: dict
        :param proxies: proxy info for requests.
        :type proxies: dict
        :param verify: verify info for requests.
        :type verify: bool, str
        :returns: dict (using json.loads())
        """

        batch = []
        retries = kwargs.get('retries', None)
        if retries:
            del kwargs['retries']
        headers = kwargs.get('headers', None)
        if headers:
            del kwargs['headers']
        proxies = kwargs.get('proxies', None)
        if proxies:
            del kwargs['proxies']
        verify = kwargs.get('verify', None)
        if verify:
            del kwargs['verify']
        include_headers = kwargs.get('include_headers', None)
        if include_headers:
            del kwargs['include_headers']
            include_headers = Broker.sanitize_bool(include_headers)
        omit_response = kwargs.get('omit_response', None)
        if omit_response:
            del kwargs['omit_response']
            omit_response = Broker.sanitize_bool(omit_response)

        for arg in args:
            batch.append(Batch.prepare_single_request(arg))
        for key, value in kwargs.iteritems():
            batch.append(Batch.prepare_single_request(value, name=key))
        params = {t.ACCESS_TOKEN: get_access_token(),
                  t.BATCH: json.dumps(batch),
                  t.INCLUDE_HEADERS: include_headers,
                  t.OMIT_RESPONSE_ON_SUCCESS: omit_response}
        try:
            return Broker.post(t.URL,
                               params=params,
                               retries=retries,
                               headers=headers,
                               proxies=proxies,
                               verify=verify)
        except:
            raise pytxFetchError('Error with batch request.')
开发者ID:abhuyan,项目名称:ThreatExchange,代码行数:77,代码来源:batch.py


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