Created
January 25, 2013 06:35
-
-
Save rmehta/4632216 to your computer and use it in GitHub Desktop.
Extract System Managers from Frappe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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