gunicorn/scripts/update_thanks.py
Hugo e974f30517 Drop support for Python 2
Co-Authored-By: Dustin Ingram <di@users.noreply.github.com>
Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
2018-08-01 15:31:17 +03:00

41 lines
1.1 KiB
Python

#!/usr/bin/env python
# Usage: git log --format="%an <%ae>" | python update_thanks.py
# You will get a result.txt file, you can work with the file (update, remove, ...)
#
# Install
# =======
# pip install validate_email pyDNS
#
import sys
from validate_email import validate_email
from email.utils import parseaddr
import DNS.Base
addresses = set()
bad_addresses = set()
collection = []
lines = list(reversed(sys.stdin.readlines()))
for author in map(str.strip, lines):
realname, email_address = parseaddr(author)
if email_address not in addresses:
if email_address in bad_addresses:
continue
else:
try:
value = validate_email(email_address)
if value:
addresses.add(email_address)
collection.append(author)
else:
bad_addresses.add(email_address)
except DNS.Base.TimeoutError:
bad_addresses.add(email_address)
with open('result.txt', 'w') as output:
output.write('\n'.join(collection))