utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:django-celery-monitor 作者: jezdez 项目源码 文件源码
def fixedwidth(field, name=None, pt=6, width=16, maxlen=64, pretty=False):
    """Render a field with a fixed width."""
    @display_field(name or field, field)
    def f(task):
        val = getattr(task, field)
        if pretty:
            val = pformat(val, width=width)
        if val.startswith("u'") or val.startswith('u"'):
            val = val[2:-1]
        shortval = val.replace(',', ',\n')
        shortval = shortval.replace('\n', '|br/|')

        if len(shortval) > maxlen:
            shortval = shortval[:maxlen] + '...'
        styled = FIXEDWIDTH_STYLE.format(
            escape(val[:255]), pt, escape(shortval),
        )
        return styled.replace('|br/|', '<br/>')
    return f
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号