本文整理汇总了Python中outwiker.core.application.Application.onPostWikiOpen方法的典型用法代码示例。如果您正苦于以下问题:Python Application.onPostWikiOpen方法的具体用法?Python Application.onPostWikiOpen怎么用?Python Application.onPostWikiOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类outwiker.core.application.Application
的用法示例。
在下文中一共展示了Application.onPostWikiOpen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: openWiki
# 需要导入模块: from outwiker.core.application import Application [as 别名]
# 或者: from outwiker.core.application.Application import onPostWikiOpen [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
示例2: openWiki
# 需要导入模块: from outwiker.core.application import Application [as 别名]
# 或者: from outwiker.core.application.Application import onPostWikiOpen [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