Mercurial > moin > 1.9
changeset 993:1547a168325a
mail package whitespace-only cleanup
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 19 Jul 2006 11:13:15 +0200 |
parents | 6d9eeabb2bd9 |
children | 862edd1566bb |
files | MoinMoin/mail/mailimport.py MoinMoin/mail/sendmail.py |
diffstat | 2 files changed, 27 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/mail/mailimport.py Wed Jul 19 09:32:14 2006 +0200 +++ b/MoinMoin/mail/mailimport.py Wed Jul 19 11:13:15 2006 +0200 @@ -33,7 +33,7 @@ self.filename = filename self.mimetype = mimetype self.data = data - + def __repr__(self): return "<attachment filename=%r mimetype=%r size=%i bytes>" % ( self.filename, self.mimetype, len(self.data)) @@ -58,27 +58,27 @@ attachments = [] html_data = [] text_data = [] - + to_addr = parseaddr(decode_2044(message['To'])) from_addr = parseaddr(decode_2044(message['From'])) cc_addr = parseaddr(decode_2044(message['Cc'])) bcc_addr = parseaddr(decode_2044(message['Bcc'])) - + subject = decode_2044(message['Subject']) date = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(mktime_tz(parsedate_tz(message['Date'])))) - + log("Processing mail:\n To: %r\n From: %r\n Subject: %r" % (to_addr, from_addr, subject)) - + for part in message.walk(): log(" Part " + repr((part.get_charsets(), part.get_content_charset(), part.get_content_type(), part.is_multipart(), ))) ct = part.get_content_type() cs = part.get_content_charset() or "latin1" payload = part.get_payload(None, True) - + fn = part.get_filename() if fn is not None and fn.startswith("=?"): # heuristics ... fn = decode_2044(fn) - + if fn is None and part["Content-Disposition"] is not None and "attachment" in part["Content-Disposition"]: # this doesn't catch the case where there is no content-disposition but there is a file to offer to the user # i hope that this can be only found in mails that are older than 10 years, @@ -107,7 +107,7 @@ generate_summary = False choose_html = True - + pagename_tpl = "" for addr in ('to_addr', 'cc_addr', 'bcc_addr'): if msg[addr][1].strip().lower() == wiki_address: @@ -121,7 +121,7 @@ # special fix for outlook users :-) if pagename_tpl[-1] == pagename_tpl[0] == "'": pagename_tpl = pagename_tpl[1:-1] - + if pagename_tpl.endswith("/"): pagename_tpl += email_subpage_template @@ -166,7 +166,7 @@ wiki_address = request.cfg.mail_import_wiki_address or request.cfg.mail_from request.user = user.get_by_email_address(request, msg['from_addr'][1]) - + if not request.user: raise ProcessingError("No suitable user found for mail address %r" % (msg['from_addr'][1], )) @@ -175,14 +175,14 @@ generate_summary = d['generate_summary'] comment = u"Mail: '%s'" % (msg['subject'], ) - + page = PageEditor(request, pagename, do_editor_backup=0) - + if not request.user.may.save(page, "", 0): raise ProcessingError("Access denied for page %r" % pagename) attachments = [] - + for att in msg['attachments']: i = 0 while 1: @@ -221,11 +221,11 @@ page.saveText(new_content, 0, comment=comment) except page.AccessDenied: raise ProcessingError("Access denied for page %r" % pagename) - + if generate_summary and "/" in pagename: parent_page = u"/".join(pagename.split("/")[:-1]) old_content = Page(request, parent_page).get_raw_body().splitlines() - + found_table = None table_ends = None for lineno, line in enumerate(old_content): @@ -235,7 +235,7 @@ table_ends = lineno + 1 elif table_ends is not None and not line.startswith("||"): break - + table_header = (u"\n\n## mail_overview (don't delete this line)\n" + u"|| '''[[GetText(From)]] ''' || '''[[GetText(To)]] ''' || '''[[GetText(Subject)]] ''' || '''[[GetText(Date)]] ''' || '''[[GetText(Link)]] ''' || '''[[GetText(Attachments)]] ''' ||\n" )
--- a/MoinMoin/mail/sendmail.py Wed Jul 19 09:32:14 2006 +0200 +++ b/MoinMoin/mail/sendmail.py Wed Jul 19 11:13:15 2006 +0200 @@ -26,14 +26,13 @@ @type charset: email.Charset.Charset instance @rtype: string @return: encoded address - """ - composite = re.compile(r'(?P<phrase>.+)(?P<angle_addr>\<.*\>)', - re.UNICODE) + """ + composite = re.compile(r'(?P<phrase>.+)(?P<angle_addr>\<.*\>)', re.UNICODE) match = composite.match(address) if match: phrase = match.group('phrase').encode(config.charset) phrase = str(Header(phrase, charset)) - angle_addr = match.group('angle_addr').encode(config.charset) + angle_addr = match.group('angle_addr').encode(config.charset) return phrase + angle_addr else: return address.encode(config.charset) @@ -59,9 +58,9 @@ from email.Utils import formatdate, make_msgid _ = request.getText - cfg = request.cfg + cfg = request.cfg mail_from = kw.get('mail_from', '') or cfg.mail_from - subject = subject.encode(config.charset) + subject = subject.encode(config.charset) # Create a text/plain body using CRLF (see RFC2822) text = text.replace(u'\n', u'\r\n') @@ -74,19 +73,19 @@ charset = Charset(config.charset) charset.header_encoding = QP charset.body_encoding = QP - msg.set_charset(charset) + msg.set_charset(charset) msg.set_payload(charset.body_encode(text)) - + # Create message headers # Don't expose emails addreses of the other subscribers, instead we # use the same mail_from, e.g. u"Jürgen Wiki <noreply@mywiki.org>" - address = encodeAddress(mail_from, charset) + address = encodeAddress(mail_from, charset) msg['From'] = address msg['To'] = address msg['Date'] = formatdate() msg['Message-ID'] = make_msgid() msg['Subject'] = Header(subject, charset) - + if cfg.mail_sendmail: # Set the BCC. This will be stripped later by sendmail. msg['BCC'] = ','.join(to) @@ -121,12 +120,12 @@ return (0, str(e)) except (os.error, socket.error), e: return (0, _("Connection to mailserver '%(server)s' failed: %(reason)s") % { - 'server': cfg.mail_smarthost, + 'server': cfg.mail_smarthost, 'reason': str(e) }) else: try: - sendmailp = os.popen(cfg.mail_sendmail, "w") + sendmailp = os.popen(cfg.mail_sendmail, "w") # msg contains everything we need, so this is a simple write sendmailp.write(msg.as_string()) sendmail_status = sendmailp.close()