本文整理汇总了Python中MoinMoin.wikiutil.isPicture函数的典型用法代码示例。如果您正苦于以下问题:Python isPicture函数的具体用法?Python isPicture怎么用?Python isPicture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isPicture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attachment
def attachment(self, url_and_text, **kw):
""" This gets called on attachment URLs.
"""
_ = self._
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
inline = url[0] == 'i'
drawing = url[0] == 'd'
url = url.split(":", 1)[1]
url = wikiutil.url_unquote(url, want_unicode=True)
text = text or url
from MoinMoin.action import AttachFile
if drawing:
return self.formatter.attachment_drawing(url, text)
# check for image URL, and possibly return IMG tag
# (images are always inlined, just like for other URLs)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(url):
return self.formatter.attachment_image(url)
# inline the attachment
if inline:
return self.formatter.attachment_inlined(url, text)
return self.formatter.attachment_link(url, text)
示例2: attachment
def attachment(self, target_and_text, **kw):
""" This gets called on attachment URLs """
_ = self._
scheme, fname, text = wikiutil160a.split_wiki(target_and_text)
pagename, fname = AttachFile.absoluteName(fname, self.pagename)
from_this_page = pagename == self.pagename
fname = self._replace(('FILE', pagename, fname))
#fname = wikiutil.url_unquote(fname)
#fname = self._replace(('FILE', pagename, fname))
pagename = self._replace(('PAGE', pagename))
if from_this_page:
name = fname
else:
name = "%s/%s" % (pagename, fname)
fn_txt = name
if text:
fn_txt += '|' + text
if scheme == 'drawing':
return "{{drawing:%s}}" % fn_txt
# check for image, and possibly return IMG tag (images are always inlined)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
return "{{attachment:%s}}" % fn_txt
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s}}' % fn_txt
return '[[attachment:%s]]' % fn_txt
示例3: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
# Local extended link?
if word[1] == ":":
words = word[2:-1].split(":", 1)
if len(words) == 1:
words = words * 2
words[0] = "wiki:Self:%s" % words[0]
return self.interwiki(words, pretty_url=1)
# return self._word_repl(words[0], words[1])
# Traditional split on space
words = word[1:-1].split(None, 1)
if len(words) == 1:
words = words * 2
if words[0][0] == "#":
# anchor link
return self.formatter.url(1, words[0]) + self.formatter.text(words[1]) + self.formatter.url(0)
scheme = words[0].split(":", 1)[0]
if scheme == "wiki":
return self.interwiki(words, pretty_url=1)
if scheme in self.attachment_schemas:
return self.attachment(words, pretty_url=1)
if wikiutil.isPicture(words[1]) and re.match(self.url_rule, words[1]):
return (
self.formatter.url(1, words[0], css="external")
+ self.formatter.image(title=words[0], alt=words[0], src=words[1])
+ self.formatter.url(0)
)
else:
return self.formatter.url(1, words[0], css=scheme) + self.formatter.text(words[1]) + self.formatter.url(0)
示例4: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link?
if word[0] == ':':
words = word[1:].split(':', 1)
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
# Traditional split on space
words = word.split(None, 1)
if words[0][0] == '#':
# anchor link
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
#link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
scheme = words[0].split(":", 1)[0]
if scheme == "wiki":
return self.interwiki(words)
#scheme, wikiname, pagename, text = self.interwiki(word)
#print "%r %r %r %r" % (scheme, wikiname, pagename, text)
#if wikiname in ('Self', self.request.cfg.interwikiname, ''):
# if text:
# text = '|' + text
# return '[[%s%s]]' % (pagename, text)
#else:
# if text:
# text = '|' + text
# return "[[%s:%s%s]]" % (wikiname, pagename, text)
if scheme in self.attachment_schemas:
m = self.attachment(words)
if m.startswith('{{') and m.endswith('}}'):
# with url_bracket markup, 1.5.8 parser does not embed, but link!
m = '[[%s]]' % m[2:-2]
return m
target, desc = (words + ['', ''])[:2]
if wikiutil.isPicture(desc) and re.match(self.url_rule, desc):
#return '[[%s|{{%s|%s}}]]' % (words[0], words[1], words[0])
return '[[%s|{{%s}}]]' % (target, desc)
else:
if desc:
desc = '|' + desc
return '[[%s%s]]' % (target, desc)
示例5: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == 'wiki':
return self.interwiki(word)
if scheme in self.attachment_schemas:
return '%s' % self.attachment(word)
if wikiutil.isPicture(word): # magic will go away in 1.6!
return '{{%s}}' % word # new markup for inline images
else:
return word
示例6: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link? [:page name:link text] XXX DEPRECATED
if word[0] == ':':
words = word[1:].split(':', 1)
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
link = self._replace_target(link)
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
scheme_and_rest = word.split(":", 1)
if len(scheme_and_rest) == 1: # no scheme
# Traditional split on space
words = word.split(None, 1)
if words[0].startswith('#'): # anchor link
link, text = (words + ['', ''])[:2]
if link.strip() == text.strip():
text = ''
if text:
text = '|' + text
return '[[%s%s]]' % (link, text)
else:
scheme = scheme_and_rest[0]
if scheme == "wiki":
return self.interwiki(word, pretty_url=1)
if scheme in self.attachment_schemas:
m = self.attachment(word)
if scheme == 'attachment':
# with url_bracket markup, 1.6.0a parser does not embed pictures, but link!
return '[[%s]]' % m[2:-2]
else:
# drawing and inline
return m
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
target, text = words
if wikiutil.isPicture(text) and re.match(self.url_rule, text):
return '[[%s|{{%s}}]]' % (target, text)
else:
if target == text:
return '[[%s]]' % target
else:
return '[[%s|%s]]' % (target, text)
示例7: interwiki
def interwiki(self, url_and_text, **kw):
# TODO: maybe support [wiki:Page http://wherever/image.png] ?
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
# keep track of whether this is a self-reference, so links
# are always shown even the page doesn't exist.
is_self_reference = 0
url2 = url.lower()
if url2.startswith("wiki:self:"):
url = url[10:] # remove "wiki:self:"
is_self_reference = 1
elif url2.startswith("wiki:"):
url = url[5:] # remove "wiki:"
tag, tail = wikiutil.split_wiki(url)
if text is None:
if tag:
text = tail
else:
text = url
url = ""
elif (
url.startswith(wikiutil.CHILD_PREFIX)
or is_self_reference # fancy link to subpage [wiki:/SubPage text]
or Page(self.request, url).exists() # [wiki:Self:LocalPage text] or [:LocalPage:text]
): # fancy link to local page [wiki:LocalPage text]
return self._word_repl(url, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
href = wikiutil.join_wiki(wikiurl, wikitail)
# check for image URL, and possibly return IMG tag
if not kw.get("pretty_url", 0) and wikiutil.isPicture(wikitail):
return self.formatter.image(src=href)
# link to self?
if wikitag is None:
return self._word_repl(wikitail)
return (
self.formatter.interwikilink(1, tag, tail)
+ self.formatter.text(text)
+ self.formatter.interwikilink(0, tag, tail)
)
示例8: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == "wiki": return self.interwiki([word])
if scheme in self.attachment_schemas:
return self.attachment([word])
if wikiutil.isPicture(word):
# Get image name http://here.com/dir/image.gif -> image
name = word.split('/')[-1]
name = ''.join(name.split('.')[:-1])
return self.formatter.image(src=word, alt=name)
else:
return (self.formatter.url(1, word, type='www') +
self.formatter.text(word) +
self.formatter.url(0))
示例9: _url_repl
def _url_repl(self, word):
"""Handle literal URLs including inline images."""
scheme = word.split(":", 1)[0]
if scheme == "wiki":
return self.interwiki([word])
if scheme in self.attachment_schemas:
return self.attachment([word])
if wikiutil.isPicture(word):
word = wikiutil.mapURL(self.request, word)
# Get image name http://here.com/dir/image.gif -> image
name = word.split("/")[-1]
name = "".join(name.split(".")[:-1])
return self.formatter.image(src=word, alt=name)
else:
return self.formatter.url(1, word, css=scheme) + self.formatter.text(word) + self.formatter.url(0)
示例10: _url_bracket_repl
def _url_bracket_repl(self, word):
"""Handle bracketed URLs."""
word = word[1:-1] # strip brackets
# Local extended link? [:page name:link text] XXX DEPRECATED
if word[0] == ':':
words = word[1:].split(':', 1)
pagename = self._replace(('PAGE', words[0]))
if len(words) == 1 or len(words) == 2 and not words[1]:
return '[[%s]]' % (pagename, )
else:
return '[[%s|%s]]' % (pagename, words[1])
scheme_and_rest = word.split(":", 1)
if len(scheme_and_rest) == 1: # no scheme
# Traditional split on space
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
if words[0].startswith('#'): # anchor link
if words[0] == words[1]:
return '[[%s]]' % words[0]
else:
return '[[%s|%s]]' % tuple(words)
else:
scheme, rest = scheme_and_rest
if scheme == "wiki":
return self.interwiki(word, pretty_url=1)
if scheme in self.attachment_schemas:
return self.attachment(word)
words = word.split(None, 1)
if len(words) == 1:
words = words * 2
target, text = words
if wikiutil.isPicture(text) and re.match(self.url_rule, text):
return '[[%s|{{%s}}]]' % (target, text)
else:
if target == text:
return '[[%s]]' % target
else:
return '[[%s|%s]]' % (target, text)
示例11: attachment
def attachment(self, target_and_text, **kw):
""" This gets called on attachment URLs """
_ = self._
scheme, fname, text = wikiutil160a.split_wiki(target_and_text)
fn_txt = fname
if text:
fn_txt += '|' + text
if scheme == 'drawing':
return "{{drawing:%s}}" % fn_txt
# check for image, and possibly return IMG tag (images are always inlined)
if not kw.get('pretty_url', 0) and wikiutil.isPicture(fname):
return "{{attachment:%s}}" % fn_txt
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s}}' % fn_txt
return '[[attachment:%s]]' % fn_txt
示例12: interwiki
def interwiki(self, target_and_text, **kw):
scheme, rest = target_and_text.split(':', 1)
wikiname, pagename, text = wikiutil160a.split_wiki(rest)
#if (pagename.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
# Page(self.request, pagename).exists()): # fancy link to local page [wiki:LocalPage text]
# # XXX OtherWiki:FooPage markup -> checks for local FooPage -sense???
# pagename = wikiutil.url_unquote(pagename)
# pagename = self._replace_target(pagename)
# return '[[%s%s]]' % (pagename, text)
if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
orig_pagename = pagename
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
camelcase = wikiutil.isStrictWikiname(pagename)
if camelcase and (not text or text == orig_pagename):
return pagename # optimize special case
else:
if text:
text = '|' + text
return '[[%s%s]]' % (pagename, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, wikiname+':')
if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that!
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
wikitail = pagename
else: # good
wikitail = wikiutil.url_unquote(pagename)
# link to self?
if wikiutil.isPicture(wikitail):
return '{{%s:%s%s}}' % (wikitag, wikitail, text)
else:
if ' ' not in wikitail and not text:
return '%s:%s' % (wikitag, wikitail)
else:
if text:
text = '|' + text
return '[[%s:%s%s]]' % (wikitag, wikitail, text)
示例13: interwiki
def interwiki(self, url_and_text):
if len(url_and_text) == 1:
url = url_and_text[0]
text = ''
else:
url, text = url_and_text
text = '|' + text
# keep track of whether this is a self-reference, so links
# are always shown even the page doesn't exist.
scheme, url = url.split(':', 1)
wikiname, pagename = wikiutil.split_wiki(url)
if (url.startswith(wikiutil.CHILD_PREFIX) or # fancy link to subpage [wiki:/SubPage text]
Page(self.request, url).exists()): # fancy link to local page [wiki:LocalPage text]
pagename = wikiutil.url_unquote(url)
pagename = self._replace_target(pagename)
return '[[%s%s]]' % (pagename, text)
if wikiname in ('Self', self.request.cfg.interwikiname, ''): # [wiki:Self:LocalPage text] or [:LocalPage:text]
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
return '[[%s%s]]' % (pagename, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
if wikitag_bad: # likely we got some /InterWiki as wikitail, we don't want that!
pagename = wikiutil.url_unquote(pagename)
pagename = self._replace_target(pagename)
wikitail = pagename
else: # good
wikitail = wikiutil.url_unquote(wikitail)
# link to self?
if wikiutil.isPicture(wikitail):
return '{{%s:%s%s}}' % (wikitag, wikitail, text)
else:
if ' ' not in wikitail and not text:
return '%s:%s' % (wikitag, wikitail)
else:
return '[[%s:%s%s]]' % (wikitag, wikitail, text)
示例14: interwiki
def interwiki(self, url_and_text, **kw):
# TODO: maybe support [wiki:Page http://wherever/image.png] ?
if len(url_and_text) == 1:
url = url_and_text[0]
text = None
else:
url, text = url_and_text
url = url[5:] # remove "wiki:"
if text is None:
tag, tail = wikiutil.split_wiki(url)
if tag:
text = tail
else:
text = url
url = ""
elif config.allow_subpages and url.startswith(wikiutil.CHILD_PREFIX):
# fancy link to subpage [wiki:/SubPage text]
return self._word_repl(url, text)
elif Page(self.request, url).exists():
# fancy link to local page [wiki:LocalPage text]
return self._word_repl(url, text)
wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_wiki(self.request, url)
href = wikiutil.join_wiki(wikiurl, wikitail)
# check for image URL, and possibly return IMG tag
if not kw.get('pretty_url', 0) and wikiutil.isPicture(wikitail):
return self.formatter.image(src=href)
# link to self?
if wikitag is None:
return self._word_repl(wikitail)
return (self.formatter.interwikilink(1, wikitag, wikitail) +
self.formatter.text(text) +
self.formatter.interwikilink(0))
示例15: attachment
def attachment(self, url_and_text):
""" This gets called on attachment URLs. """
if len(url_and_text) == 1:
url = url_and_text[0]
text = ''
else:
url, text = url_and_text
text = '|' + text
scheme, fname = url.split(":", 1)
#scheme, fname, text = wikiutil.split_wiki(target_and_text)
pagename, fname = AttachFile.absoluteName(fname, self.pagename)
from_this_page = pagename == self.pagename
fname = self._replace(('FILE', pagename, fname))
fname = wikiutil.url_unquote(fname)
fname = self._replace(('FILE', pagename, fname))
pagename = self._replace(('PAGE', pagename))
if from_this_page:
name = fname
else:
name = "%s/%s" % (pagename, fname)
if scheme == 'drawing':
return "{{drawing:%s%s}}" % (name, text)
# check for image URL, and possibly return IMG tag
# (images are always inlined, just like for other URLs)
if wikiutil.isPicture(name):
return "{{attachment:%s%s}}" % (name, text)
# inline the attachment
if scheme == 'inline':
return '{{attachment:%s%s}}' % (name, text)
else: # 'attachment'
return '[[attachment:%s%s]]' % (name, text)