scriptutils.py 文件源码

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

项目:remoteControlPPT 作者: htwenning 项目源码 文件源码
def GetActiveFileName(bAutoSave = 1):
    """Gets the file name for the active frame, saving it if necessary.

    Returns None if it cant be found, or raises KeyboardInterrupt.
    """
    pathName = None
    active = GetActiveView()
    if active is None:
        return None
    try:
        doc = active.GetDocument()
        pathName = doc.GetPathName()

        if bAutoSave and \
            (len(pathName)>0 or \
            doc.GetTitle()[:8]=="Untitled" or \
            doc.GetTitle()[:6]=="Script"): # if not a special purpose window
            if doc.IsModified():
                try:
                    doc.OnSaveDocument(pathName)
                    pathName = doc.GetPathName()

                    # clear the linecache buffer
                    linecache.clearcache()

                except win32ui.error:
                    raise KeyboardInterrupt

    except (win32ui.error, AttributeError):
        pass
    if not pathName:
        return None
    return pathName
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号