utils.py 文件源码

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

项目:NS_Proj 作者: drstarry 项目源码 文件源码
def vPrint(actor, sent, otherActor, toPrint, base64encode=True):
    """does verbose printing of stuff, with cutoffs for length and base 64
    encoding
    """
    if VERBOSE:
        label = "%s -> %s" % (actor, otherActor)
        if not sent:
            label = "%s <- %s" % (actor, otherActor)
        if len(label) < 12:
            label = label + (" " * (12 - len(label)))
        if type(toPrint) == str:
            if base64encode:
                toPrint = b64encode(toPrint)
            if len(toPrint) > 100:
                toPrint = toPrint[:100] + "..."
        elif type(toPrint) == list:
            if base64encode:
                toPrint = [b64encode(x) if len(x) < 100
                           else b64encode(x[:100]) + '...' for x in toPrint]
            else:
                toPrint = [x if len(x) < 100
                           else x[:100] + '...' for x in toPrint]
        print "%s: <%s>" % (label, toPrint)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号