本文整理汇总了Python中Mailman.Utils.to_dollar方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.to_dollar方法的具体用法?Python Utils.to_dollar怎么用?Python Utils.to_dollar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mailman.Utils
的用法示例。
在下文中一共展示了Utils.to_dollar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_list_categories
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import to_dollar [as 别名]
def _do_list_categories(self, mlist, k, subcat=None):
is_converted = bool(getattr(mlist, 'use_dollar_strings', False))
info = mlist.GetConfigInfo(k, subcat)
label, gui = mlist.GetConfigCategories()[k]
if info is None:
return
for data in info[1:]:
if not isinstance(data, tuple):
continue
varname = data[0]
# Variable could be volatile
if varname.startswith('_'):
continue
vtype = data[1]
# Munge the value based on its type
value = None
if hasattr(gui, 'getValue'):
value = gui.getValue(mlist, vtype, varname, data[2])
if value is None:
value = getattr(mlist, varname)
# Do %-string to $-string conversions if the list hasn't already
# been converted.
if varname == 'use_dollar_strings':
continue
if not is_converted and varname in DOLLAR_STRINGS:
value = Utils.to_dollar(value)
widget_type = TYPES[vtype]
if isinstance(value, list):
self._push_element('option', name=varname, type=widget_type)
for v in value:
self._element('value', v)
self._pop_element('option')
else:
self._element('option', value, name=varname, type=widget_type)
示例2: convert
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import to_dollar [as 别名]
def convert(mlist):
for attr in ('msg_header', 'msg_footer', 'digest_header', 'digest_footer',
'autoresponse_postings_text', 'autoresponse_admin_text',
'autoresponse_request_text'):
s = getattr(mlist, attr)
t = Utils.to_dollar(s)
setattr(mlist, attr, t)
mlist.use_dollar_strings = 1
print _('Saving list')
mlist.Save()
示例3: _convertString
# 需要导入模块: from Mailman import Utils [as 别名]
# 或者: from Mailman.Utils import to_dollar [as 别名]
def _convertString(self, mlist, property, alloweds, val, doc):
# Is the list using $-strings?
dollarp = getattr(mlist, 'use_dollar_strings', 0)
if dollarp:
ids = Utils.dollar_identifiers(val)
else:
# %-strings
ids = Utils.percent_identifiers(val)
# Here's the list of allowable interpolations
for allowed in alloweds:
if ids.has_key(allowed):
del ids[allowed]
if ids:
# What's left are not allowed
badkeys = ids.keys()
badkeys.sort()
bad = BADJOINER.join(badkeys)
doc.addError(_(
"""The following illegal substitution variables were
found in the <code>%(property)s</code> string:
<code>%(bad)s</code>
<p>Your list may not operate properly until you correct this
problem."""), tag=_('Warning: '))
return val
# Now if we're still using %-strings, do a roundtrip conversion and
# see if the converted value is the same as the new value. If not,
# then they probably left off a trailing `s'. We'll warn them and use
# the corrected string.
if not dollarp:
fixed = Utils.to_percent(Utils.to_dollar(val))
if fixed <> val:
doc.addError(_(
"""Your <code>%(property)s</code> string appeared to
have some correctable problems in its new value.
The fixed value will be used instead. Please
double check that this is what you intended.
"""))
return fixed
return val