evernote_exporter.py 文件源码

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

项目:evernote-exporter 作者: shawndaniel 项目源码 文件源码
def edit_file(self, full_path, filename, to_zim=False):
        text_maker = html2text.HTML2Text()

        with open(full_path, 'r') as f:
            html = f.read()
        content = ''
        if html:
            try:
                content = text_maker.handle(unicode(html, errors='ignore'))
                content = content.encode('ascii', 'ignore')
                content = content.split('\00')[0]   # remove null chars
                content = content.replace('\.', '.')    # remove escape chars
            except Exception as e:
                self._exception('convert content of note to markdown', full_path, e)
        else:
            content = ''

        if to_zim:
            content = self.to_zim_syntax(content)

        fn_path = self._rename_file(full_path, filename)
        with open(fn_path, 'w') as f:
            try:
                f.write(content.encode('ascii', 'ignore'))
            except Exception as e:
                self._exception('save note', fn_path, e)
        return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号