Guest User

Untitled

a guest
Nov 2nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. From bill@whitehouse.gov
  2. To buffy@airhead.net
  3. Date Saturday, October 4, 1997
  4. Subject Get together
  5. Hey, honeypie. Ole Big Daddy sure is missin you. I’ll be a
  6. lookin for you to come around again this weekend.
  7. Love,
  8. Bill
  9.  
  10. From veep@whitehouse.gov
  11. To buddha@whitehouse.gov
  12. Date Monday, October 6, 1997
  13. Subject BM
  14. Dear Buddha, I just had a BM. Please advise.
  15.  
  16. From reno@justice.gov
  17. To bill@whitehouse.gov
  18. Date Wednesday, October 8, 1997
  19. Subject Roby Ridge
  20.  
  21. Mr. President:
  22. The situation with the lady in Roby is quickly deteriorating.
  23. I advise we use an Apache loaded with napalm to flush the crazy
  24. woman out. If it kills her, it serves her right for that Vaseline
  25. trick. Dead or alive, at least it will be over. If I don’t hear
  26. from you within the next hour, I’ll send for the chopper.
  27. Janet
  28.  
  29. From buddha@whitehouse.gov
  30. To veep@whitehouse.gov
  31. Date Saturday, November 8, 1997
  32. Subject Re: BM
  33.  
  34. Thank you for advising me of your BM. You may not have
  35. another BM until Monday, November 3, 1997.
  36.  
  37. import datetime
  38.  
  39. def search_match(t, f):
  40. return t.startswith('From veep@whitehouse.gov') and f.startswith('To buddha@whitehouse.gov')
  41.  
  42. def get_date(date):
  43. prefix = date.strftime('%A, %B ')
  44. day = date.strftime('%d').lstrip('0')
  45. postfix = date.strftime(', %Y')
  46. return '{0}{1}{2}'.format(prefix, day, postfix)
  47.  
  48. with open('whmail.log') as f:
  49. for line in f:
  50. if search_match(line, f.readline()):
  51. date, subject = datetime.datetime.strptime(f.readline().strip()[5:], "%A, %B %d, %Y"), f.readline()
  52. subject = 'Re:' + subject[7:]
  53. limit = date + datetime.timedelta(days=28)
  54. sent = limit + datetime.timedelta(days=5)
  55. print('From veep@whitehouse.govnTo buddha@whitehouse.govnDate {0}nSubject {1}nThank you for advising me of your BM. You may not havenanother BM until {2}'.format(get_date(sent), subject, get_date(limit)))
Add Comment
Please, Sign In to add comment