attribution.py 841 B

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