attribution.py 878 B

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