def get_content_as_text(emailmessage): """Get email as text""" part = emailmessage.get_body(preferencelist=('plain')) if part == None: #no plain type, try html part = emailmessage.get_body(preferencelist=('html')) text = part.get_payload(decode=True).decode('UTF-8') text = html2text.html2text(text) else: #go on with text text = part.get_payload(decode=True).decode('UTF-8') text = html.unescape(text) return (text.strip())
def request_close(cur, uid, reqid, reason): user = username_from_id(cur, uid) pkgbase_id = pkgbase_from_pkgreq(cur, reqid) to = [aur_request_ml] cc = get_request_recipients(cur, pkgbase_id, uid) text = sys.stdin.read() user_uri = aur_location + '/account/' + user + '/' subject = '[PRQ#%d] Request %s' % (int(reqid), reason.title()) body = 'Request #%d has been %s by %s [1]' % (int(reqid), reason, user) if text.strip() == '': body += '.\n\n' else: body += ':\n\n' + text + '\n\n' body += '[1] ' + user_uri thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>' send_notification(to, subject, body, cc, thread_id)
def request_close(conn, uid, reqid, reason): to = [aur_request_ml] cc = get_request_recipients(conn, reqid) text = get_request_closure_comment(conn, reqid) subject = '[PRQ#%d] Request %s' % (int(reqid), reason.title()) if int(uid): user = username_from_id(conn, uid) user_uri = aur_location + '/account/' + user + '/' body = 'Request #%d has been %s by %s [1]' % (int(reqid), reason, user) refs = '[1] ' + user_uri else: body = 'Request #%d has been %s automatically by the Arch User ' \ 'Repository package request system' % (int(reqid), reason) refs = None if text.strip() == '': body += '.' else: body += ':\n\n' + text thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>' headers = headers_reply(thread_id) headers.update(headers_cc(cc)) send_notification(to, subject, body, refs, headers)
def _convert_tags(self, text): """Replace _TAGS_ with placeholders. %(TAG)s""" text = text.strip("'\"") for tag in _TAG_RE.findall(text): self.tags.add(tag[1]) return _TAG_RE.sub(r"%(\2)s", text)