RDKitXL_server.py 文件源码

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

项目:rdkit4excel 作者: janholstjensen 项目源码 文件源码
def BuildTypelib(idlfile = "RDKitXL.idl"):
    this_dir = os.path.dirname(__file__)
    idl = os.path.abspath(os.path.join(this_dir, idlfile))
    basename = idlfile.split('.')[0]
    tlb=os.path.splitext(idl)[0] + '.tlb'
    prev_idl = idl + ".previous"

    this_idl_txt = "".join(open(idl, 'r').readlines())
    previous_idl_txt = "does not exist"
    if os.path.isfile(prev_idl):
        previous_idl_txt = "".join(open(prev_idl, 'r').readlines())

    if this_idl_txt != previous_idl_txt:
        print("Compiling %s." % (idl,))
        rc = os.system ('midl "%s"' % (idl,))
        if rc:
            raise RuntimeError("Compiling MIDL failed!")
        # Can't work out how to prevent MIDL from generating the stubs.
        # just nuke them
        for fname in ("dlldata.c %s_i.c %s_p.c %s.h"%(basename, basename, basename)).split():
            os.remove(os.path.join(this_dir, fname))
        open(prev_idl, 'w').write("".join(open(idl, 'r').readlines()))

    else:
        print("No IDL changes.")

    print("Registering %s." % (tlb,))
    tli=pythoncom.LoadTypeLib(tlb)
    pythoncom.RegisterTypeLib(tli,tlb)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号