generate_html_preview.py 文件源码

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

项目:alfred-unicode 作者: deanishe 项目源码 文件源码
def main():
    start = time()
    count = 0
    items = []
    with open(TSV_FILE, 'rb') as fp:
        reader = csv.reader(fp, delimiter=b'\t')
        for row in reader:
            name, h, entity = [v.decode('utf-8') for v in row]
            s = '\\u{}'.format(h)
            u = unicode_escape_decode(s)[0]
            # char = '?'
            log.info(u)
            count += 1
            items.append(ICON_TPL.format(char=u, info='U+{}'.format(h)))
            if LIMIT and count == LIMIT:
                break
    html = PAGE_TPL.format(content='\n'.join(items), style=STYLE_TPL)

    with open(HTML_FILE, 'wb') as fp:
        fp.write(html.encode('utf-8'))

    log.info('{:d} icons generated in {:0.2f} seconds'.format(
             count, time() - start))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号