本文整理汇总了Python中Mailman.Utils.findtext方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.findtext方法的具体用法?Python Utils.findtext怎么用?Python Utils.findtext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mailman.Utils
的用法示例。
在下文中一共展示了Utils.findtext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: quick_maketext
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import findtext [as 别名]
def quick_maketext(templatefile, dict=None, lang=None, mlist=None):
"""Create an output using a template"""
# Used by various html output functions such as as_html, html_TOC and write_index_entry
if mlist is None:
listname = ''
else:
listname = mlist._internal_name
if lang is None:
if mlist is None:
lang = mm_cfg.DEFAULT_SERVER_LANGUAGE
else:
lang = mlist.preferred_language
cachekey = (templatefile, lang, listname)
filepath = _templatefilepathcache.get(cachekey)
if filepath:
template = _templatecache.get(filepath)
if filepath is None or template is None:
# Use the basic maketext, with defaults to get the raw template
template, filepath = Utils.findtext(templatefile, lang=lang,
raw=True, mlist=mlist)
_templatefilepathcache[cachekey] = filepath
_templatecache[filepath] = template
# Copied from Utils.maketext()
text = template
if dict is not None:
try:
sdict = SafeDict(dict)
try:
text = sdict.interpolate(template)
except UnicodeError:
# Try again after coercing the template to unicode
utemplate = unicode(template,
Utils.GetCharSet(lang),
'replace')
text = sdict.interpolate(utemplate)
except (TypeError, ValueError):
# The template is really screwed up
pass
# Make sure the text is in the given character set, or html-ify any bogus
# characters.
return Utils.uncanonstr(text, lang)
示例2: quick_maketext
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import findtext [as 别名]
def quick_maketext(templatefile, dict=None, lang=None, mlist=None):
if mlist is None:
listname = ''
else:
listname = mlist._internal_name
if lang is None:
if mlist is None:
lang = mm_cfg.DEFAULT_SERVER_LANGUAGE
else:
lang = mlist.preferred_language
cachekey = (templatefile, lang, listname)
filepath = _templatefilepathcache.get(cachekey)
if filepath:
template = _templatecache.get(filepath)
if filepath is None or template is None:
# Use the basic maketext, with defaults to get the raw template
template, filepath = Utils.findtext(templatefile, lang=lang,
raw=True, mlist=mlist)
_templatefilepathcache[cachekey] = filepath
_templatecache[filepath] = template
# Copied from Utils.maketext()
text = template
if dict is not None:
try:
sdict = SafeDict(dict)
try:
text = sdict.interpolate(template)
except UnicodeError:
# Try again after coercing the template to unicode
utemplate = unicode(template,
Utils.GetCharSet(lang),
'replace')
text = sdict.interpolate(utemplate)
except (TypeError, ValueError), e:
# The template is really screwed up
syslog('error', 'broken template: %s\n%s', filepath, e)