attribution.py 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. from __future__ import absolute_import
  3. import fileinput
  4. from pprint import pprint
  5. def author(line):
  6. try:
  7. A, E = line.strip().rsplit(None, 1)
  8. E.replace(">", "").replace("<", "")
  9. except ValueError:
  10. A, E = line.strip(), None
  11. return A.lower() if A else A, E.lower() if E else E
  12. def proper_name(name):
  13. return name and " " in name
  14. def find_missing_authors(seen):
  15. with open("AUTHORS") as authors:
  16. known = map(author, authors.readlines())
  17. seen_authors = set(filter(proper_name, (t[0] for t in seen)))
  18. seen_emails = set(t[1] for t in seen)
  19. known_authors = set(t[0] for t in known)
  20. known_emails = set(t[1] for t in known)
  21. pprint(seen_authors - known_authors)
  22. if __name__ == "__main__":
  23. find_missing_authors(map(author, fileinput.input()))