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


Python structures.mapping_iterator函数代码示例

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


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

示例1: _flatten

 def _flatten(self, meta):
     for key, value in mapping_iterator(meta):
         if isinstance(value, Mapping):
             for child, value in self._flatten(value):
                 yield '%s_%s' % (key, child), value
         else:
             yield key, self._to_string(value)
开发者ID:tourist,项目名称:lux,代码行数:7,代码来源:contents.py

示例2: _flatten

def _flatten(meta):
    for key, value in mapping_iterator(meta):
        if isinstance(value, Mapping):
            for child, v in _flatten(value):
                yield '%s_%s' % (key, child), v
        else:
            yield key, _flatten_value(value)
开发者ID:quantmind,项目名称:lux,代码行数:7,代码来源:contents.py

示例3: __call__

 def __call__(self, response, **kw):
     r = response.request
     url, headers, _ = self._client.sign(
         r.url, r.method, r.body, r.headers)
     for key, value in mapping_iterator(headers):
         r.add_header(key, value)
     r.url = url
开发者ID:quantmind,项目名称:pulsar,代码行数:7,代码来源:oauth.py

示例4: _ready

 def _ready(self, data):
     charset = self.charset
     data = parse_qs(data.decode(charset), keep_blank_values=True)
     forms = self.result[0]
     for key, values in mapping_iterator(data):
         for value in values:
             forms[key] = value
     return self.result
开发者ID:successtest9,项目名称:pulsar,代码行数:8,代码来源:formdata.py

示例5: __call__

 def __call__(self, response, exc=None):
     r = response.request
     url, headers, data = self._client.sign(r.full_url, r.method, r.data,
                                            r.headers)
     for key, value in mapping_iterator(headers):
         r.add_header(key, value)
     r.full_url = url
     r.data = data
开发者ID:arhik,项目名称:pulsar,代码行数:8,代码来源:oauth.py

示例6: _ready

 def _ready(self, data):
     self.environ["wsgi.input"] = BytesIO(data)
     charset = self.charset
     data = parse_qs(data.decode(charset), keep_blank_values=True)
     forms = self.result[0]
     for key, values in mapping_iterator(data):
         for value in values:
             forms[key] = value
     return self.result
开发者ID:Pastafarianist,项目名称:pulsar,代码行数:9,代码来源:formdata.py

示例7: __init__

 def __init__(self, proxies=None, headers=None, verify=True,
              cookies=None, store_cookies=True, cert=None,
              max_redirects=10, decompress=True, version=None,
              websocket_handler=None, parser=None, trust_env=True,
              loop=None, client_version=None, timeout=None, stream=False,
              pool_size=10, frame_parser=None, logger=None,
              close_connections=False, keep_alive=None):
     super().__init__(
         partial(Connection, HttpResponse),
         loop=loop,
         keep_alive=keep_alive or cfg_value('http_keep_alive')
     )
     self.logger = logger or LOGGER
     self.client_version = client_version or self.client_version
     self.connection_pools = {}
     self.pool_size = pool_size
     self.trust_env = trust_env
     self.timeout = timeout
     self.store_cookies = store_cookies
     self.max_redirects = max_redirects
     self.cookies = cookiejar_from_dict(cookies)
     self.decompress = decompress
     self.version = version or self.version
     # SSL Verification default
     self.verify = verify
     # SSL client certificate default, if String, path to ssl client
     # cert file (.pem). If Tuple, ('cert', 'key') pair
     self.cert = cert
     self.stream = stream
     self.close_connections = close_connections
     dheaders = CIMultiDict(self.DEFAULT_HTTP_HEADERS)
     dheaders['user-agent'] = self.client_version
     # override headers
     if headers:
         for name, value in mapping_iterator(headers):
             if value is None:
                 dheaders.pop(name, None)
             else:
                 dheaders[name] = value
     self.headers = dheaders
     self.proxies = dict(proxies or ())
     if not self.proxies and self.trust_env:
         self.proxies = get_environ_proxies()
         if 'no' not in self.proxies:
             self.proxies['no'] = ','.join(self.no_proxy)
     self.websocket_handler = websocket_handler
     self.http_parser = parser or http.HttpResponseParser
     self.frame_parser = frame_parser or websocket.frame_parser
     # Add hooks
     self.event('on_headers').bind(handle_cookies)
     self.event('pre_request').bind(WebSocket())
     self.event('post_request').bind(Expect())
     self.event('post_request').bind(Redirect())
     self._decompressors = dict(
         gzip=GzipDecompress(),
         deflate=DeflateDecompress()
     )
开发者ID:quantmind,项目名称:pulsar,代码行数:57,代码来源:client.py

示例8: full_url

def full_url(url, params, method=None):
    p = urlparse(url)
    if not p.netloc and method == 'CONNECT':
        p = urlparse('http://%s' % url)

    params = mapping_iterator(params)
    query = parse_qsl(p.query)
    query.extend(split_url_params(params))
    query = urlencode(query)
    return urlunparse((p.scheme, p.netloc, p.path,
                       p.params, query, p.fragment))
开发者ID:wilddom,项目名称:pulsar,代码行数:11,代码来源:__init__.py

示例9: _encode_url

 def _encode_url(self, data):
     query = self.query
     if data:
         data = native_str(data)
         if isinstance(data, str):
             data = parse_qsl(data)
         else:
             data = mapping_iterator(data)
         query = parse_qsl(query)
         query.extend(data)
         query = urlencode(query)
     self.query = query
开发者ID:successtest9,项目名称:pulsar,代码行数:12,代码来源:__init__.py

示例10: get

    def get(self, request):
        '''Get all routes grouped in sections.

        This is the only method available for the router base route.'''
        if request.response.content_type in JSON_CONTENT_TYPES:
            json = Json(as_list=True)
            for name, section in mapping_iterator(self.sections):
                json.append(OrderedDict((('name', name),
                                         ('routes', section.json(request)))))
            return json.http_response(request)
        else:
            raise HttpException(status=415)
开发者ID:pombredanne,项目名称:lux,代码行数:12,代码来源:__init__.py

示例11: _full_url

    def _full_url(self, url, params):
        """Full url of endpoint
        """
        p = urlparse(url)
        if not p.netloc and self.method == 'CONNECT':
            p = urlparse('http://%s' % url)

        params = mapping_iterator(params)
        query = parse_qsl(p.query)
        query.extend(split_url_params(params))
        query = urlencode(query)
        return urlunparse((p.scheme, p.netloc, p.path,
                           p.params, query, p.fragment))
开发者ID:yl849646685,项目名称:pulsar,代码行数:13,代码来源:__init__.py

示例12: _encode_url

 def _encode_url(self, body):
     query = self.query
     if body:
         body = native_str(body)
         if isinstance(body, str):
             body = parse_qsl(body)
         else:
             body = mapping_iterator(body)
         query = parse_qsl(query)
         query.extend(body)
         self.data = query
         query = urlencode(query)
     self.query = query
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:13,代码来源:__init__.py

示例13: _encode_files

 def _encode_files(self, data):
     fields = []
     for field, val in mapping_iterator(data or ()):
         if isinstance(val, str) or isinstance(val, bytes) or not hasattr(val, "__iter__"):
             val = [val]
         for v in val:
             if v is not None:
                 if not isinstance(v, bytes):
                     v = str(v)
                 fields.append(
                     (
                         field.decode("utf-8") if isinstance(field, bytes) else field,
                         v.encode("utf-8") if isinstance(v, str) else v,
                     )
                 )
     for (k, v) in mapping_iterator(self.files):
         # support for explicit filename
         ft = None
         if isinstance(v, (tuple, list)):
             if len(v) == 2:
                 fn, fp = v
             else:
                 fn, fp, ft = v
         else:
             fn = guess_filename(v) or k
             fp = v
         if isinstance(fp, bytes):
             fp = BytesIO(fp)
         elif isinstance(fp, str):
             fp = StringIO(fp)
         if ft:
             new_v = (fn, fp.read(), ft)
         else:
             new_v = (fn, fp.read())
         fields.append((k, new_v))
     #
     return encode_multipart_formdata(fields, charset=self.charset)
开发者ID:nmg1986,项目名称:pulsar,代码行数:37,代码来源:__init__.py

示例14: process_meta

def process_meta(meta, cfg):
    as_list = MultiValue()
    for key, values in mapping_iterator(meta):
        key = slugify(key, separator='_')
        if not isinstance(values, (list, tuple)):
            values = (values,)
        if key not in METADATA_PROCESSORS:
            bits = key.split('_', 1)
            values = guess(as_list(values, cfg))
            if len(bits) > 1 and bits[0] == 'meta':
                k = '_'.join(bits[1:])
                yield k, values
            else:
                yield key, values
        #
        elif values:
            process = METADATA_PROCESSORS[key]
            yield key, process(values, cfg)
开发者ID:quantmind,项目名称:lux,代码行数:18,代码来源:contents.py

示例15: update

 def update(self, iterable):
     for name, value in mapping_iterator(iterable):
         self[name] = value
开发者ID:pombredanne,项目名称:lux,代码行数:3,代码来源:base.py


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