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


Python builtins.dict方法代码示例

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


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

示例1: error

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def error(self, proto, *args):
        if proto in ('http', 'https'):
            # XXX http[s] protocols are special-cased
            dict = self.handle_error['http'] # https is not different than http
            proto = args[2]  # YUCK!
            meth_name = 'http_error_%s' % proto
            http_err = 1
            orig_args = args
        else:
            dict = self.handle_error
            meth_name = proto + '_error'
            http_err = 0
        args = (dict, proto, meth_name) + args
        result = self._call_chain(*args)
        if result:
            return result

        if http_err:
            args = (dict, 'default', 'http_error_default') + orig_args
            return self._call_chain(*args)

# XXX probably also want an abstract factory that knows when it makes
# sense to skip a superclass in favor of a subclass and when it might
# make sense to include both 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:26,代码来源:request.py

示例2: test_proxy

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def test_proxy(self):
        o = OpenerDirector()
        ph = urllib_request.ProxyHandler(dict(http="proxy.example.com:3128"))
        o.add_handler(ph)
        meth_spec = [
            [("http_open", "return response")]
            ]
        handlers = add_ordered_mock_handlers(o, meth_spec)

        req = Request("http://acme.example.com/")
        self.assertEqual(req.host, "acme.example.com")
        o.open(req)
        self.assertEqual(req.host, "proxy.example.com:3128")

        self.assertEqual([(handlers[0], "http_open")],
                         [tup[0:2] for tup in o.calls]) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:18,代码来源:test_urllib2.py

示例3: test_proxy_https_proxy_authorization

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def test_proxy_https_proxy_authorization(self):
        o = OpenerDirector()
        ph = urllib_request.ProxyHandler(dict(https='proxy.example.com:3128'))
        o.add_handler(ph)
        https_handler = MockHTTPSHandler()
        o.add_handler(https_handler)
        req = Request("https://www.example.com/")
        req.add_header("Proxy-Authorization","FooBar")
        req.add_header("User-Agent","Grail")
        self.assertEqual(req.host, "www.example.com")
        self.assertIsNone(req._tunnel_host)
        o.open(req)
        # Verify Proxy-Authorization gets tunneled to request.
        # httpsconn req_headers do not have the Proxy-Authorization header but
        # the req will have.
        self.assertNotIn(("Proxy-Authorization","FooBar"),
                         https_handler.httpconn.req_headers)
        self.assertIn(("User-Agent","Grail"),
                      https_handler.httpconn.req_headers)
        self.assertIsNotNone(req._tunnel_host)
        self.assertEqual(req.host, "proxy.example.com:3128")
        self.assertEqual(req.get_header("Proxy-authorization"),"FooBar")

    # TODO: This should be only for OSX 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:26,代码来源:test_urllib2.py

示例4: test_proxy_basic_auth

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def test_proxy_basic_auth(self):
        opener = OpenerDirector()
        ph = urllib_request.ProxyHandler(dict(http="proxy.example.com:3128"))
        opener.add_handler(ph)
        password_manager = MockPasswordManager()
        auth_handler = urllib_request.ProxyBasicAuthHandler(password_manager)
        realm = "ACME Networks"
        http_handler = MockHTTPHandler(
            407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm)
        opener.add_handler(auth_handler)
        opener.add_handler(http_handler)
        self._test_basic_auth(opener, auth_handler, "Proxy-authorization",
                              realm, http_handler, password_manager,
                              "http://acme.example.com:3128/protected",
                              "proxy.example.com:3128",
                              ) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:18,代码来源:test_urllib2.py

示例5: end_struct

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def end_struct(self, data):
        mark = self._marks.pop()
        # map structs to Python dictionaries
        dict = {}
        items = self._stack[mark:]
        for i in range(0, len(items), 2):
            dict[items[i]] = items[i+1]
        self._stack[mark:] = [dict]
        self._value = 0 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:11,代码来源:client.py

示例6: __getitem__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def __getitem__(self, i):
        item = self.results[i]
        if isinstance(type(item), dict):
            raise Fault(item['faultCode'], item['faultString'])
        elif type(item) == type([]):
            return item[0]
        else:
            raise ValueError("unexpected type in multicall result") 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:10,代码来源:client.py

示例7: single_request

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def single_request(self, host, handler, request_body, verbose=False):
        # issue XML-RPC request
        try:
            http_conn = self.send_request(host, handler, request_body, verbose)
            resp = http_conn.getresponse()
            if resp.status == 200:
                self.verbose = verbose
                return self.parse_response(resp)

        except Fault:
            raise
        except Exception:
            #All unexpected errors leave connection in
            # a strange state, so we clear it.
            self.close()
            raise

        #We got an error response.
        #Discard any response data and raise exception
        if resp.getheader("content-length", ""):
            resp.read()
        raise ProtocolError(
            host + handler,
            resp.status, resp.reason,
            dict(resp.getheaders())
            )


    ##
    # Create parser.
    #
    # @return A 2-tuple containing a parser and a unmarshaller. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:34,代码来源:client.py

示例8: getparser

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def getparser(self):
        # get parser and unmarshaller
        return getparser(use_datetime=self._use_datetime,
                         use_builtin_types=self._use_builtin_types)

    ##
    # Get authorization info from host parameter
    # Host may be a string, or a (host, x509-dict) tuple; if a string,
    # it is checked for a "user:pw@host" format, and a "Basic
    # Authentication" header is added if appropriate.
    #
    # @param host Host descriptor (URL or (URL, x509 info) tuple).
    # @return A 3-tuple containing (actual host, extra headers,
    #     x509 info).  The header and x509 fields may be None. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:16,代码来源:client.py

示例9: make_connection

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def make_connection(self, host):
        if self._connection and host == self._connection[0]:
            return self._connection[1]

        if not hasattr(http_client, "HTTPSConnection"):
            raise NotImplementedError(
            "your version of http.client doesn't support HTTPS")
        # create a HTTPS connection object from a host descriptor
        # host may be a string, or a (host, x509-dict) tuple
        chost, self._extra_headers, x509 = self.get_host_info(host)
        self._connection = host, http_client.HTTPSConnection(chost,
            None, **(x509 or {}))
        return self._connection[1]

##
# Standard server proxy.  This class establishes a virtual connection
# to an XML-RPC server.
# <p>
# This class is available as ServerProxy and Server.  New code should
# use ServerProxy, to avoid confusion.
#
# @def ServerProxy(uri, **options)
# @param uri The connection point on the server.
# @keyparam transport A transport factory, compatible with the
#    standard transport class.
# @keyparam encoding The default encoding used for 8-bit strings
#    (default is UTF-8).
# @keyparam verbose Use a true value to enable debugging output.
#    (printed to standard output).
# @see Transport 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:32,代码来源:client.py

示例10: redirect_request

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def redirect_request(self, req, fp, code, msg, headers, newurl):
        """Return a Request or None in response to a redirect.

        This is called by the http_error_30x methods when a
        redirection response is received.  If a redirection should
        take place, return a new Request to allow http_error_30x to
        perform the redirect.  Otherwise, raise HTTPError if no-one
        else should try to handle this url.  Return None if you can't
        but another Handler might.
        """
        m = req.get_method()
        if (not (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
            or code in (301, 302, 303) and m == "POST")):
            raise HTTPError(req.full_url, code, msg, headers, fp)

        # Strictly (according to RFC 2616), 301 or 302 in response to
        # a POST MUST NOT cause a redirection without confirmation
        # from the user (of urllib.request, in this case).  In practice,
        # essentially all clients do redirect in this case, so we do
        # the same.
        # be conciliant with URIs containing a space
        newurl = newurl.replace(' ', '%20')
        CONTENT_HEADERS = ("content-length", "content-type")
        newheaders = dict((k, v) for k, v in req.headers.items()
                          if k.lower() not in CONTENT_HEADERS)
        return Request(newurl,
                       headers=newheaders,
                       origin_req_host=req.origin_req_host,
                       unverifiable=True)

    # Implementation note: To avoid the server sending us into an
    # infinite loop, the request object needs to track what URLs we
    # have already seen.  Do this by adding a handler-specific
    # attribute to the Request object. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:36,代码来源:request.py

示例11: __repr__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import dict [as 别名]
def __repr__(self):
        # Without this, will just display as a defaultdict
        return "<Quoter %r>" % dict(self) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:5,代码来源:parse.py


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