genpy.py 文件源码

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

项目:pupy 作者: ru-faraon 项目源码 文件源码
def WriteEnumerationItems(self, stream):
    num = 0
    enumName = self.doc[0]
    # Write in name alpha order
    names = list(self.mapVars.keys())
    names.sort()
    for name in names:
      entry = self.mapVars[name]
      vdesc = entry.desc
      if vdesc[4] == pythoncom.VAR_CONST:
        val = vdesc[1]

        use = repr(val)
        # Make sure the repr of the value is valid python syntax
        # still could cause an error on import if it contains a module or type name
        # not available in the global namespace
        try:
            compile(use, '<makepy>', 'eval')
        except SyntaxError:
            # At least add the repr as a string, so it can be investigated further
            # Sanitize it, in case the repr contains its own quotes.  (??? line breaks too ???)
            use = use.replace('"',"'")
            use = '"' + use + '"' + ' # This VARIANT type cannot be converted automatically'
        print >> stream, "\t%-30s=%-10s # from enum %s" % \
                      (build.MakePublicAttributeName(name, True), use, enumName)
        num += 1
    return num
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号