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


Python pep.to_string函数代码示例

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


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

示例1: login_response

 def login_response(self, request, user):
     session = self.create_session(request, user)
     request.cache.session = session
     token = to_string(session.encoded)
     request.response.status_code = 201
     return Json({'success': True,
                  'token': token}).http_response(request)
开发者ID:pvanderlinden,项目名称:lux,代码行数:7,代码来源:mixins.py

示例2: decript

 def decript(self, password=None):
     if password:
         p = self.crypt_module.decrypt(to_bytes(password, self.encoding),
                                       self.secret_key)
         return to_string(p, self.encoding)
     else:
         return UNUSABLE_PASSWORD
开发者ID:SirZazu,项目名称:lux,代码行数:7,代码来源:user.py

示例3: parse_info

def parse_info(response):
    info = {}
    response = to_string(response)

    def get_value(value):
        if "," not in value or "=" not in value:
            try:
                if "." in value:
                    return float(value)
                else:
                    return int(value)
            except ValueError:
                return value
        else:
            sub_dict = {}
            for item in value.split(","):
                k, v = item.rsplit("=", 1)
                sub_dict[k] = get_value(v)
            return sub_dict

    for line in response.splitlines():
        if line and not line.startswith("#"):
            key, value = line.split(":", 1)
            info[key] = get_value(value)
    return info
开发者ID:quantmind,项目名称:pulsar,代码行数:25,代码来源:client.py

示例4: _form_message

 def _form_message(self, container, key, msg):
     if msg:
         msg = to_string(msg)
         if key in container:
             container[key].append(msg)
         else:
             container[key] = [msg]
开发者ID:pombredanne,项目名称:lux,代码行数:7,代码来源:form.py

示例5: values

 def values(self, bfield):
     '''Generator of values in select'''
     for o in self.all(bfield):
         if isinstance(o, Widget):
             v = o.attr('value')
         else:
             v = to_string(o[0])
         yield v
开发者ID:pombredanne,项目名称:lux,代码行数:8,代码来源:fields.py

示例6: _to_string

 def _to_string(self, value):
     if isinstance(value, Mapping):
         raise BuildError('A dictionary found when coverting to string')
     elif isinstance(value, (list, tuple)):
         return ', '.join(self._to_string(v) for v in value)
     elif isinstance(value, date):
         return iso8601(value)
     else:
         return to_string(value)
开发者ID:tourist,项目名称:lux,代码行数:9,代码来源:contents.py

示例7: to_string

    def to_string(self, stream):
        '''Once the :class:`.Future`, returned by :meth:`content`
        method, is ready, this method get called to transform the stream into
        the content string. This method can be overwritten by derived classes.

        :param stream: a collections containing ``strings/bytes`` used to
            build the final ``string/bytes``.
        :return: a string or bytes
        '''
        return to_string(''.join(stream_to_string(stream)))
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:10,代码来源:content.py

示例8: to_string

    def to_string(self, streams):
        '''Called to transform the collection of
        ``streams`` into the content string.
        This method can be overwritten by derived classes.

        :param streams: a collection (list or dictionary) containing
            ``strings/bytes`` used to build the final ``string/bytes``.
        :return: a string or bytes
        '''
        return to_string(''.join(stream_to_string(streams)))
开发者ID:imclab,项目名称:pulsar,代码行数:10,代码来源:content.py

示例9: _render_meta

 def _render_meta(self, value, context):
     if isinstance(value, Mapping):
         return dict(((k, self._render_meta(v, context))
                      for k, v in value.items()))
     elif isinstance(value, (list, tuple)):
         return [self._render_meta(v, context) for v in value]
     elif isinstance(value, date):
         return value
     elif value is not None:
         return self._engine(to_string(value), context)
开发者ID:tourist,项目名称:lux,代码行数:10,代码来源:contents.py

示例10: _clean_simple

 def _clean_simple(self, value, bfield):
     '''Invoked by :meth:`clean` if :attr:`model` is not defined.'''
     choices = self.choices
     if hasattr(choices, '__call__'):
         choices = choices(bfield)
     if not isinstance(choices, Mapping):
         choices = dict(choices)
     values = value if self.multiple else (value,)
     for v in values:
         v = to_string(v)
         if v not in choices:
             raise ValidationError('%s is not a valid choice' % v)
     return value
开发者ID:pombredanne,项目名称:lux,代码行数:13,代码来源:fields.py

示例11: broadcast

 def broadcast(self, channel, message):
     '''Broadcast ``message`` to all :attr:`clients`.'''
     remove = set()
     channel = to_string(channel)
     message = self.decode(message)
     clients = tuple(self.clients)
     for client in clients:
         try:
             client(channel, message)
         except Exception:
             LOGGER.exception('Exception while processing pub/sub client. '
                              'Removing it.')
             remove.add(client)
     self.clients.difference_update(remove)
开发者ID:elimisteve,项目名称:pulsar,代码行数:14,代码来源:__init__.py

示例12: dataReceived

 def dataReceived(self, data):
     sep = self.separator
     idx = data.find(sep)
     if idx >= 0:
         if self.buffer:
             msg = self.buffer + msg
             self.buffer = b''
         id, msg, data = data[:8], data[8:idx], data[idx+len(sep):]
         d = self.requests.pop(id)
         d.callback(to_string(msg))
         if data:
             self.dataReceived(data)
     else:
         self.buffer += data
开发者ID:JinsongBian,项目名称:pulsar,代码行数:14,代码来源:test_tx.py

示例13: _clean

 def _clean(self, value, bfield):
     try:
         value = to_string(value)
     except Exception:
         raise ValidationError
     if self.toslug:
         value = slugify(value, self.toslug)
     if self.char_transform:
         if self.char_transform == 'u':
             value = value.upper()
         else:
             value = value.lower()
     if self.required and not value:
         raise ValidationError(
             self.validation_error.format(bfield.name, value))
     return value
开发者ID:pombredanne,项目名称:lux,代码行数:16,代码来源:fields.py

示例14: broadcast

 def broadcast(self, response):
     '''Broadcast ``message`` to all :attr:`clients`.'''
     remove = set()
     channel = to_string(response[0])
     message = response[1]
     if self._protocol:
         message = self._protocol.decode(message)
     for client in self._clients:
         try:
             client(channel, message)
         except IOError:
             remove.add(client)
         except Exception:
             self._loop.logger.exception(
                 'Exception while processing pub/sub client. Removing it.')
             remove.add(client)
     self._clients.difference_update(remove)
开发者ID:nmg1986,项目名称:pulsar,代码行数:17,代码来源:store.py

示例15: execute

 def execute(self, request):
     '''Execute a new ``request``.
     '''
     handle = None
     if request:
         request[0] = command = to_string(request[0]).lower()
         info = COMMANDS_INFO.get(command)
         if info:
             handle = getattr(self.store, info.method_name)
         #
         if self.channels or self.patterns:
             if command not in self.store.SUBSCRIBE_COMMANDS:
                 return self.reply_error(self.store.PUBSUB_ONLY)
         if self.blocked:
             return self.reply_error('Blocked client cannot request')
         if self.transaction is not None and command not in 'exec':
             self.transaction.append((handle, request))
             return self._transport.write(self.store.QUEUED)
     self._execute_command(handle, request)
开发者ID:LJS109,项目名称:pulsar,代码行数:19,代码来源:client.py


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