command.py 文件源码

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

项目:jiveplot 作者: haavee 项目源码 文件源码
def maybePage(lst):
    screenSize = getScreenSize()
    # be more intelligent about it
    doPage = None
    if screenSize:
        # count the number of lines the text would use up on the screen
        # (taking care of lines longer than the terminal width)
        doPage = sum( \
            map(lambda x: \
                sum( map(lambda y: \
                          int(math.ceil(float(len(y) if len(y) else 1)/float(screenSize[1]))), x.split('\n') \
                    ) \
                ), lst \
            )) > screenSize[0]
    if doPage or not screenSize:
        pydoc.pager("\n".join(lst))
    else:
        def p(x):
            print x
        map(p, lst)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号