本文整理汇总了Python中Mailman.i18n._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setValue
def _setValue(self, mlist, property, val, doc):
# Do value conversion from web representation to internal
# representation.
try:
if property == 'bounce_processing':
val = int(val)
elif property == 'bounce_score_threshold':
val = float(val)
elif property == 'bounce_info_stale_after':
val = days(int(val))
elif property == 'bounce_you_are_disabled_warnings':
val = int(val)
elif property == 'bounce_you_are_disabled_warnings_interval':
val = days(int(val))
elif property == 'bounce_notify_owner_on_disable':
val = int(val)
elif property == 'bounce_notify_owner_on_removal':
val = int(val)
except ValueError:
doc.addError(
_("""Bad value for <a href="?VARHELP=bounce/%(property)s"
>%(property)s</a>: %(val)s"""),
tag = _('Error: '))
return
GUIBase._setValue(self, mlist, property, val, doc)
示例2: GetStandardReplacements
def GetStandardReplacements(self, lang=None):
dmember_len = len(self.getDigestMemberKeys())
member_len = len(self.getRegularMemberKeys())
# If only one language is enabled for this mailing list, omit the
# language choice buttons.
if len(self.GetAvailableLanguages()) == 1:
listlangs = _(Utils.GetLanguageDescr(self.preferred_language))
else:
listlangs = self.GetLangSelectBox(lang).Format()
d = {
'<mm-mailman-footer>' : self.GetMailmanFooter(),
'<mm-list-name>' : self.real_name,
'<mm-email-user>' : self._internal_name,
'<mm-list-description>' : Utils.websafe(self.description),
'<mm-list-info>' :
'<!---->' + BR.join(self.info.split(NL)) + '<!---->',
'<mm-form-end>' : self.FormatFormEnd(),
'<mm-archive>' : self.FormatArchiveAnchor(),
'</mm-archive>' : '</a>',
'<mm-list-subscription-msg>' : self.FormatSubscriptionMsg(),
'<mm-restricted-list-message>' : \
self.RestrictedListMessage(_('The current archive'),
self.archive_private),
'<mm-num-reg-users>' : `member_len`,
'<mm-num-digesters>' : `dmember_len`,
'<mm-num-members>' : (`member_len + dmember_len`),
'<mm-posting-addr>' : '%s' % self.GetListEmail(),
'<mm-request-addr>' : '%s' % self.GetRequestEmail(),
'<mm-owner>' : self.GetOwnerEmail(),
'<mm-reminder>' : self.FormatReminder(self.preferred_language),
'<mm-host>' : self.host_name,
'<mm-list-langs>' : listlangs,
}
示例3: loginpage
def loginpage(mlist, scriptname, msg='', frontpage=None):
url = mlist.GetScriptURL(scriptname)
if frontpage:
actionurl = url
else:
actionurl = Utils.GetRequestURI(url)
if msg:
msg = FontAttr(msg, color='#ff0000', size='+1').Format()
# give an HTTP 401 for authentication failure
print 'Status: 401 Unauthorized'
if scriptname == 'admindb':
who = _('Moderator')
else:
who = _('Administrator')
# Language stuff
charset = Utils.GetCharSet(mlist.preferred_language)
print 'Content-type: text/html; charset=' + charset + '\n\n'
print Utils.maketext(
'admlogin.html',
{'listname': mlist.real_name,
'path' : actionurl,
'message' : msg,
'who' : who,
}, mlist=mlist)
print mlist.GetMailmanFooter()
示例4: maybe_forward
def maybe_forward(mlist, msg):
# Does the list owner want to get non-matching bounce messages?
# If not, simply discard it.
if mlist.bounce_unrecognized_goes_to_list_owner:
adminurl = mlist.GetScriptURL('admin', absolute=1) + '/bounce'
mlist.ForwardMessage(msg,
text=_("""\
The attached message was received as a bounce, but either the bounce format
was not recognized, or no member addresses could be extracted from it. This
mailing list has been configured to send all unrecognized bounce messages to
the list administrator(s).
For more information see:
%(adminurl)s
"""),
subject=_('Uncaught bounce notification'),
tomoderators=0)
syslog('bounce',
'%s: forwarding unrecognized, message-id: %s',
mlist.internal_name(),
msg.get('message-id', 'n/a'))
else:
syslog('bounce',
'%s: discarding unrecognized, message-id: %s',
mlist.internal_name(),
msg.get('message-id', 'n/a'))
示例5: _setValue
def _setValue(self, mlist, property, val, doc):
# Watch for the special, immediate action attributes
if property == "_new_volume" and val:
mlist.bump_digest_volume()
volume = mlist.volume
number = mlist.next_digest_number
doc.AddItem(
_(
"""The next digest will be sent as volume
%(volume)s, number %(number)s"""
)
)
elif property == "_send_digest_now" and val:
status = mlist.send_digest_now()
if status:
doc.AddItem(_("""A digest has been sent."""))
else:
doc.AddItem(_("""There was no digest to send."""))
else:
# Everything else...
if property in ("digest_header", "digest_footer"):
val = self._convertString(mlist, property, ALLOWEDS, val, doc)
if val is None:
# There was a problem, so don't set it
return
GUIBase._setValue(self, mlist, property, val, doc)
示例6: OpenIDOption
def OpenIDOption(self, lang):
#from Cgi import client
container = Container()
hostname = mm_cfg.DEFAULT_URL_HOST
hostid = mm_cfg.DEFAULT_OID_CONSUMER
# if self.private_roster == 0:
# either = _('<b><i>either</i></b> ')
# else:
# either = ''
# realname = self.real_name
container.AddItem(Hidden('language', lang))
if not self.private_roster:
container.AddItem(_("Click here for the list of ")
+ self.real_name
+ _(" subscribers: "))
container.AddItem(SubmitButton('LoginThrough',
_("Visit Subscriber list")))
else:
if self.private_roster == 1:
only = _('members')
whom = _('Address:')
else:
only = _('the list administrator')
whom = _('Admin address:')
container.AddItem(_("<B> <p>Use Common ")
# + whom[:-1].lower()
+ _("Authentication to access"
" <a href='http://%(hostname)s:%(hostid)s'> all lists</a> <p> </B> ")
+ _("<p> <B> You can enable Common Authentication <a href='http://%(hostname)s/mailman/openidreg'> Enable </a> </B>")
# + whom
+ " ")
container.AddItem("</center>")
return container
示例7: GetConfigSubCategories
def GetConfigSubCategories(self, category):
if category == 'members':
return [('list', _('Membership List')),
('add', _('Mass Subscription')),
('remove', _('Mass Removal')),
]
return None
示例8: handleForm
def handleForm(self, mlist, category, subcat, cgidata, doc):
for item in self.GetConfigInfo(mlist, category, subcat):
# Skip descriptions and legacy non-attributes
if not isinstance(item, TupleType) or len(item) < 5:
continue
# Unpack the gui item description
property, wtype, args, deps, desc = item[0:5]
# BAW: I know this code is a little crufty but I wanted to
# reproduce the semantics of the original code in admin.py as
# closely as possible, for now. We can clean it up later.
#
# The property may be uploadable...
uploadprop = property + '_upload'
if cgidata.has_key(uploadprop) and cgidata[uploadprop].value:
val = cgidata[uploadprop].value
elif not cgidata.has_key(property):
continue
elif isinstance(cgidata[property], ListType):
val = [x.value for x in cgidata[property]]
else:
val = cgidata[property].value
# Coerce the value to the expected type, raising exceptions if the
# value is invalid.
try:
val = self._getValidValue(mlist, property, wtype, val)
except ValueError:
doc.addError(_('Invalid value for variable: %(property)s'))
# This is the parent of MMBadEmailError and MMHostileAddress
except Errors.EmailAddressError, error:
doc.addError(
_('Bad email address for option %(property)s: %(error)s'))
else:
# Set the attribute, which will normally delegate to the mlist
self._setValue(mlist, property, val, doc)
示例9: process
def process(mlist, msg, msgdata):
# Extract the sender's address and find them in the user database
sender = msgdata.get('original_sender', msg.get_sender())
try:
ack = mlist.getMemberOption(sender, mm_cfg.AcknowledgePosts)
if not ack:
return
except Errors.NotAMemberError:
return
# Okay, they want acknowledgement of their post. Give them their original
# subject. BAW: do we want to use the decoded header?
origsubj = msgdata.get('origsubj', msg.get('subject', _('(no subject)')))
# Get the user's preferred language
lang = msgdata.get('lang', mlist.getMemberLanguage(sender))
# Now get the acknowledgement template
realname = mlist.real_name
text = Utils.maketext(
'postack.txt',
{'subject' : Utils.oneline(origsubj, Utils.GetCharSet(lang)),
'listname' : realname,
'listinfo_url': mlist.GetScriptURL('listinfo', absolute=1),
'optionsurl' : mlist.GetOptionsURL(sender, absolute=1),
}, lang=lang, mlist=mlist, raw=1)
# Craft the outgoing message, with all headers and attributes
# necessary for general delivery. Then enqueue it to the outgoing
# queue.
subject = _('%(realname)s post acknowledgement')
usermsg = Message.UserNotification(sender, mlist.GetBouncesEmail(),
subject, text, lang)
usermsg.send(mlist)
示例10: scrub_msg822
def scrub_msg822(self, part):
# submessage
submsg = part.get_payload(0)
omask = os.umask(002)
try:
url = save_attachment(self.mlist, part, self.dir)
finally:
os.umask(omask)
subject = submsg.get('subject', _('no subject'))
subject = Utils.oneline(subject, self.lcset)
date = submsg.get('date', _('no date'))
who = submsg.get('from', _('unknown sender'))
who = Utils.oneline(who, self.lcset)
size = len(str(submsg))
self.msgtexts.append(unicode(_("""\
An embedded message was scrubbed...
From: %(who)s
Subject: %(subject)s
Date: %(date)s
Size: %(size)s
URL: %(url)s
"""), self.lcset))
# Replace this part because subparts should not be walk()-ed.
del part['content-type']
part.set_payload('blah blah', 'us-ascii')
示例11: MailmanLogo
def MailmanLogo():
t = Table(border=0, width='100%')
version = mm_cfg.VERSION
mmlink = _("Delivered by Mailman")
pylink = _("Python Powered")
gnulink = _("GNU's Not Unix")
if mm_cfg.SITE_LINK:
sitelink = mm_cfg.SITE_TEXT
if mm_cfg.IMAGE_LOGOS:
def logo(file, alt, base=mm_cfg.IMAGE_LOGOS):
return '<img src="%s" alt="%s" border="0" />' % \
(base + file, alt)
mmlink = logo(DELIVERED_BY, mmlink)
pylink = logo(PYTHON_POWERED, pylink)
gnulink = logo(GNU_HEAD, gnulink)
if mm_cfg.SITE_LINK:
sitelink = logo(mm_cfg.SITE_LOGO, sitelink, "")
mmlink = Link(MAILMAN_URL, mmlink + _('<br>version %(version)s'))
pylink = Link(PYTHON_URL, pylink)
gnulink = Link(GNU_URL, gnulink)
links = [mmlink, pylink, gnulink]
if mm_cfg.SITE_LINK:
if mm_cfg.SITE_URL:
sitelink = Link(mm_cfg.SITE_URL, sitelink)
links.append(sitelink)
t.AddRow(links)
return t
示例12: do_discard
def do_discard(mlist, msg):
sender = msg.get_sender()
# Do we forward auto-discards to the list owners?
if mlist.forward_auto_discards:
lang = mlist.preferred_language
varhelp = '%s/?VARHELP=privacy/sender/discard_these_nonmembers' % \
mlist.GetScriptURL('admin', absolute=1)
nmsg = Message.UserNotification(mlist.GetOwnerEmail(),
mlist.GetBouncesEmail(),
_('Auto-discard notification'),
lang=lang)
nmsg.set_type('multipart/mixed')
text = MIMEText(Utils.wrap(_(
'The attached message has been automatically discarded.')),
_charset=Utils.GetCharSet(lang))
nmsg.attach(text)
decrypted = msg.get('X-Mailman-SLS-decrypted', '').lower()
if decrypted == 'yes':
syslog('gpg',
'forwarding only headers of message from %s to listmaster to notify discard since message was decrypted',
sender)
msgtext = msg.as_string()
(header, body) = msgtext.split("\n\n", 1)
nmsg.attach(MIMEText(header))
else:
nmsg.attach(MIMEMessage(msg))
nmsg.send(mlist)
# Discard this sucker
raise Errors.DiscardMessage
示例13: GetConfigSubCategories
def GetConfigSubCategories(self, category):
if category == 'privacy':
return [('subscribing', _('Subscription rules')),
('sender', _('Sender filters')),
('recipient', _('Recipient filters')),
('spam', _('Spam filters')),
]
return None
示例14: do_reject
def do_reject(mlist):
listowner = mlist.GetOwnerEmail()
if mlist.nonmember_rejection_notice:
raise Errors.RejectMessage, \
Utils.wrap(_(mlist.nonmember_rejection_notice))
else:
raise Errors.RejectMessage, Utils.wrap(_("""\
You are not allowed to post to this mailing list, and your message has been
automatically rejected. If you think that your messages are being rejected in
error, contact the mailing list owner at %(listowner)s."""))
示例15: convert
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()