recipe-579066.py 文件源码

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

项目:code 作者: ActiveState 项目源码 文件源码
def line_gen(basedir,chan):
    subdir = chan+".chat"
    sdpath = os.path.join(basedir,subdir)
    fn = max(x for x in os.listdir(sdpath) if x.endswith(".txt"))
    path = os.path.join(sdpath,fn)
    ch = chan.encode('utf-8')
    for x in tail_f(path):
        if x == EWOULDBLOCK:
            continue
        s = x.encode('utf-8')
        time,name,rest = split_line(s)
        if name[-1] == ':'.encode('utf-8'):
            t = colored(time,'cyan',attrs=['bold'])
            c = colored(ch,'cyan',attrs=['bold'])
            n = colored(name,'red',attrs=['bold'])
            r = highlight(rest)
        else:
            t = colored(time,'cyan')
            c = colored(ch,'cyan')
            n = colored(name,'yellow',attrs=['dark'])
            r = colored(rest,attrs=['dark'])   
        yield ' '.join((t,c,n,r))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号