Skip to content

Instantly share code, notes, and snippets.

@rmehta
Created January 25, 2013 06:35
Show Gist options
  • Save rmehta/4632216 to your computer and use it in GitHub Desktop.
Save rmehta/4632216 to your computer and use it in GitHub Desktop.
Extract System Managers from Frappe
from webnotes.utils import cstr, validate_email_add, extract_email_id
from email.utils import parseaddr
el = []
for s in webnotes.conn.sql("""select system_managers from `tabSerial No`
where status in ("Active", "Trial", "Delivered")"""):
if s and s[0]:
emails = cstr(s[0]).split("\n")
for e in emails:
name, addr = parseaddr(e)
if addr:
addr = addr.lower()
if not validate_email_add(addr):
addr = extract_email_id(e).lower()
if addr:
el.append(addr)
webnotes.errprint(", ".join(sorted(list(set(el)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment