Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def clone(self):
result = _WikiLinkPath()
result.upwardCount = self.upwardCount
result.components = self.components[:]
return result
instead and uses the result as suggestion for autocompletion.
If prefix is None autocompletion is not possible.
"""
linkPath = _WikiLinkPath(link=link)
if linkPath.isAbsolute():
return linkPath.resolvePrefixSilenceAndWikiWordLink(None)
if basePage is None:
return u"", 0, link # TODO: Better reaction?
basePageName = basePage.getWikiWord()
if basePageName is None:
return u"", 0, link # TODO: Better reaction?
return linkPath.resolvePrefixSilenceAndWikiWordLink(_WikiLinkPath(
pageName=basePageName))
@staticmethod
def resolvePrefixSilenceAndWikiWordLink(link, basePage):
"""
If using subpages this is used to resolve a link to the right wiki word
for autocompletion. It returns a tuple (prefix, silence, pageName).
Autocompletion now searches for all wiki words starting with pageName. For
all found items it removes the first silence characters, prepends the prefix
instead and uses the result as suggestion for autocompletion.
If prefix is None autocompletion is not possible.
"""
linkPath = _WikiLinkPath(link=link)
if linkPath.isAbsolute():
return linkPath.resolvePrefixSilenceAndWikiWordLink(None)
if basePage is None:
return u"", 0, link # TODO: Better reaction?
basePageName = basePage.getWikiWord()
if basePageName is None:
return u"", 0, link # TODO: Better reaction?
return linkPath.resolvePrefixSilenceAndWikiWordLink(_WikiLinkPath(
pageName=basePageName))
@staticmethod
def createWikiLinkPathObject(*args, **kwargs):
return _WikiLinkPath(*args, **kwargs)
@staticmethod
def createRelativeLinkFromWikiWord(word, baseWord, downwardOnly=True):
"""
Create a link to wikiword word relative to baseWord.
If downwardOnly is False, the link may contain parts to go to parents
or siblings
in path (in this wiki language, ".." are used for this).
If downwardOnly is True, the function may return None if a relative
link can't be constructed.
"""
relPath = _WikiLinkPath.getRelativePathByAbsPaths(_WikiLinkPath(
pageName=word), _WikiLinkPath(pageName=baseWord),
downwardOnly=downwardOnly)
if relPath is None:
return None
return relPath.getLinkCore()
@staticmethod
def createLinkFromWikiWord(word, wikiPage, forceAbsolute=False):
"""
Create a link from word which should be put on wikiPage.
"""
wikiDocument = wikiPage.getWikiDocument()
targetPath = _WikiLinkPath(pageName=word)
if forceAbsolute:
return BracketStart + targetPath.getLinkCore() + BracketEnd
linkCore = _TheHelper.createRelativeLinkFromWikiWord(
word, wikiPage.getWikiWord(), downwardOnly=False)
if _TheHelper.isCcWikiWord(word) and _TheHelper.isCcWikiWord(linkCore):
wikiFormatDetails = wikiPage.getFormatDetails()
if wikiFormatDetails.withCamelCase:
ccBlacklist = wikiDocument.getCcWordBlacklist()
if not word in ccBlacklist:
return linkCore
return BracketStart + linkCore + BracketEnd
@staticmethod
def isAbsoluteLinkCore(linkCore):
return _WikiLinkPath.isAbsoluteLinkCore(linkCore)
def clone(self):
result = _WikiLinkPath()
result.upwardCount = self.upwardCount
result.components = self.components[:]
return result
@staticmethod
def resolvePrefixSilenceAndWikiWordLink(link, basePage):
"""
If using subpages this is used to resolve a link to the right wiki word
for autocompletion. It returns a tuple (prefix, silence, pageName).
Autocompletion now searches for all wiki words starting with pageName. For
all found items it removes the first silence characters, prepends the prefix
instead and uses the result as suggestion for autocompletion.
If prefix is None autocompletion is not possible.
"""
linkPath = _WikiLinkPath(link=link)
if linkPath.isAbsolute():
return linkPath.resolvePrefixSilenceAndWikiWordLink(None)
if basePage is None:
return u"", 0, link # TODO: Better reaction?
basePageName = basePage.getWikiWord()
if basePageName is None:
return u"", 0, link # TODO: Better reaction?
return linkPath.resolvePrefixSilenceAndWikiWordLink(_WikiLinkPath(
pageName=basePageName))
@staticmethod
def createRelativeLinkFromWikiWord(word, baseWord, downwardOnly=True):
"""
Create a link to wikiword word relative to baseWord.
If downwardOnly is False, the link may contain parts to go to parents
or siblings
in path (in this wiki language, ".." are used for this).
If downwardOnly is True, the function may return None if a relative
link can't be constructed.
"""
relPath = _WikiLinkPath.getRelativePathByAbsPaths(_WikiLinkPath(
pageName=word), _WikiLinkPath(pageName=baseWord),
downwardOnly=downwardOnly)
if relPath is None:
return None
return relPath.getLinkCore()