genpy.py 文件源码

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

项目:CodeReader 作者: jasonrbr 项目源码 文件源码
def do_gen_file_header(self):
    la = self.typelib.GetLibAttr()
    moduleDoc = self.typelib.GetDocumentation(-1)
    docDesc = ""
    if moduleDoc[1]:
      docDesc = moduleDoc[1]

    # Reset all the 'per file' state
    self.bHaveWrittenDispatchBaseClass = 0
    self.bHaveWrittenCoClassBaseClass = 0
    self.bHaveWrittenEventBaseClass = 0
    # You must provide a file correctly configured for writing unicode.
    # We assert this is it may indicate somewhere in pywin32 that needs
    # upgrading.
    assert self.file.encoding, self.file
    encoding = self.file.encoding # or "mbcs"

    print('# -*- coding: %s -*-' % (encoding,), file=self.file)
    print('# Created by makepy.py version %s' % (makepy_version,), file=self.file)
    print('# By python version %s' % \
                        (sys.version.replace("\n", "-"),), file=self.file)
    if self.sourceFilename:
        print("# From type library '%s'" % (os.path.split(self.sourceFilename)[1],), file=self.file)
    print('# On %s' % time.ctime(time.time()), file=self.file)

    print(build._makeDocString(docDesc), file=self.file)

    print('makepy_version =', repr(makepy_version), file=self.file)
    print('python_version = 0x%x' % (sys.hexversion,), file=self.file)
    print(file=self.file)
    print('import win32com.client.CLSIDToClass, pythoncom, pywintypes', file=self.file)
    print('import win32com.client.util', file=self.file)
    print('from pywintypes import IID', file=self.file)
    print('from win32com.client import Dispatch', file=self.file)
    print(file=self.file)
    print('# The following 3 lines may need tweaking for the particular server', file=self.file)
    print('# Candidates are pythoncom.Missing, .Empty and .ArgNotFound', file=self.file)
    print('defaultNamedOptArg=pythoncom.Empty', file=self.file)
    print('defaultNamedNotOptArg=pythoncom.Empty', file=self.file)
    print('defaultUnnamedArg=pythoncom.Empty', file=self.file)
    print(file=self.file)
    print('CLSID = ' + repr(la[0]), file=self.file)
    print('MajorVersion = ' + str(la[3]), file=self.file)
    print('MinorVersion = ' + str(la[4]), file=self.file)
    print('LibraryFlags = ' + str(la[5]), file=self.file)
    print('LCID = ' + hex(la[1]), file=self.file)
    print(file=self.file)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号