mentags.py 文件源码

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

项目:txt2evernote 作者: Xunius 项目源码 文件源码
def processLine(line):

    titlep=re.compile('^# (\\w+.+$)', re.LOCALE)    #group 1
    quotep1=re.compile('^\\t> (.+$)', re.LOCALE)    #group 1
    quotep2=re.compile('^\\t  (.+$)', re.LOCALE)    #group 1
    notep1=re.compile('^\\t- (.+$)', re.LOCALE)    #group 1
    notep2=re.compile('^\\t  (.+$)', re.LOCALE)    #group 1
    citep=re.compile('^\\t\\t- (@\\w+)')  #group1
    tagsp=re.compile('^\\t\\t(- Tags: | {8})(.+$)')    #group2
    ctimep=re.compile('^\\t\\t- Ctime: (.+$)') #group1

    patterns={'title': [titlep,1],\
              'quote1': [quotep1,1],\
              'quote2': [quotep2,1],\
              'note1':  [notep1,1],\
              'note2':  [notep2,1],\
              'cite':  [citep,1],\
              'tags':  [tagsp,2],\
              'ctime': [ctimep,1]\
              }

    for kk,vv in patterns.items():
        m=vv[0].match(line)
        if m:
            return kk,m.group(vv[1]).encode('utf8')

    return None,''






#------------Organize by tags and save------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号