glifLib2.py 文件源码

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

项目:inter 作者: rsms 项目源码 文件源码
def _fetchGlyphName(glyphPath):
    # Given a path to an existing .glif file, get the glyph name
    # from the XML data.
    from xml.parsers.expat import ParserCreate

    p = ParserCreate()
    p.StartElementHandler = _startElementHandler
    p.returns_unicode = True
    f = open(glyphPath)
    try:
        p.ParseFile(f)
    except _DoneParsing, why:
        glyphName = why.args[0]
        if glyphName is None:
            raise ValueError, (".glif file doen't have a <glyph> top-level "
                    "element: %r" % glyphPath)
    else:
        assert 0, "it's not expected that parsing the file ends normally"
    return glyphName
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号