当前位置: 首页>>代码示例>>Python>>正文


Python Application.onPreWikiOpen方法代码示例

本文整理汇总了Python中outwiker.core.application.Application.onPreWikiOpen方法的典型用法代码示例。如果您正苦于以下问题:Python Application.onPreWikiOpen方法的具体用法?Python Application.onPreWikiOpen怎么用?Python Application.onPreWikiOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在outwiker.core.application.Application的用法示例。


在下文中一共展示了Application.onPreWikiOpen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: openWiki

# 需要导入模块: from outwiker.core.application import Application [as 别名]
# 或者: from outwiker.core.application.Application import onPreWikiOpen [as 别名]
def openWiki(path: str, readonly: bool=False) -> Optional[WikiDocument]:
    def threadFunc(path, readonly):
        try:
            return WikiDocument.load(path, readonly)
        except BaseException as e:
            return e

    logger.debug('Opening notes tree from: {}'.format(path))
    if not os.path.exists(path):
        __canNotLoadWikiMessage(path)
        return

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)
    if preWikiOpenParams.abortOpen:
        logger.debug('Opening notes tree aborted')
        return

    # The path may be changed in event handlers
    path = preWikiOpenParams.path
    logger.debug('Notes tree path after onPreWikiOpen: {}'.format(path))

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir(path):
        path = os.path.split(path)[0]

    runner = LongProcessRunner(threadFunc,
                               Application.mainWindow,
                               _(u"Loading"),
                               _(u"Opening notes tree..."))
    result = runner.run(os.path.realpath(path), readonly)

    success = False
    if isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    elif isinstance(result, Exception):
        logger.error(result)
        __canNotLoadWikiMessage(path)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
开发者ID:Jenyay,项目名称:outwiker,代码行数:51,代码来源:commands.py

示例2: openWiki

# 需要导入模块: from outwiker.core.application import Application [as 别名]
# 或者: from outwiker.core.application.Application import onPreWikiOpen [as 别名]
def openWiki (path, readonly=False):
    if not os.path.exists (path):
        __canNotLoadWikiMessage (path)
        return

    # Если передан путь до файла настроек (а не до папки с вики),
    # то оставим только папку
    if not os.path.isdir (path):
        path = os.path.split (path)[0]

    def threadFunc (path, readonly):
        try:
            return WikiDocument.load (path, readonly)
        except IOError as error:
            return error
        except outwiker.core.exceptions.RootFormatError as error:
            return error

    preWikiOpenParams = PreWikiOpenParams(path, readonly)
    Application.onPreWikiOpen(Application.selectedPage,
                              preWikiOpenParams)

    runner = LongProcessRunner (threadFunc,
                                Application.mainWindow,
                                _(u"Loading"),
                                _(u"Opening notes tree..."))
    result = runner.run (os.path.realpath (path), readonly)

    success = False
    if isinstance(result, IOError):
        __canNotLoadWikiMessage(path)
    elif isinstance(result, outwiker.core.exceptions.RootFormatError):
        __rootFormatErrorHandle(path, readonly)
    else:
        Application.wikiroot = result
        success = True

    postWikiOpenParams = PostWikiOpenParams(path, readonly, success)
    Application.onPostWikiOpen(Application.selectedPage,
                               postWikiOpenParams)

    return Application.wikiroot
开发者ID:,项目名称:,代码行数:44,代码来源:


注:本文中的outwiker.core.application.Application.onPreWikiOpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。