Advertisement
tyler569

secret santa

Jan 26th, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.74 KB | None | 0 0
  1. import smtplib
  2. import random
  3. import sys
  4. import os
  5. import smtplib
  6.  
  7. from email.mime.text import MIMEText
  8.  
  9.  
  10. class person(object):
  11.     def __init__(self, name, email):
  12.         self.name = name
  13.         self.email = email
  14.  
  15.     def __str__(self):
  16.         return self.name
  17.  
  18.  
  19. def santa_mail(s, name, partner):
  20.     msg = MIMEText("""
  21. Hello {name},
  22.  
  23. You are receiving this message becasue you expressed interest in
  24. the Hillenbrand 4E Secret Santa 2014.  Following
  25. is your assigned partner:
  26.  
  27. {partner}
  28.  
  29. You have until Saturday, December 6 to get them a gift,
  30. please do limit yourself to $15 as a curtesy to everyone,
  31. and try to make it something they'll enjoy!
  32.  
  33. Don't forget - your Santa is a surprise, so don't tell them
  34. who you are ;D
  35.  
  36. Thank you, and Merry Christmas,
  37. Your humble matchmaker,
  38. Tyler's Python Script.""".format(name=name, partner=partner)
  39.     )
  40.  
  41.     msg["Subject"] = "Hilly4E Secret Santa"
  42.     msg["From"] = "tphilbri@purdue.edu"
  43.     msg["To"] = name.email
  44.  
  45.     #print(msg)
  46.     #s.send_message(msg)
  47.  
  48. def getnames():
  49.     ret = []
  50.     try:
  51.         with open(sys.argv[1], "r") as f:
  52.             for l in f:
  53.                 n, m = l.split("\t")
  54.                 ret.append(person(n, m))
  55.         return ret
  56.     except Exception:
  57.         print("Error, file and stuff")
  58.         exit(1)
  59.  
  60. def oato(l):
  61.     lenl = len(l)
  62.     for i in range(lenl):
  63.         yield (l[i], l[(i + 1) % lenl])
  64.  
  65.  
  66. def main():
  67.     x = getnames()
  68.     random.shuffle(x)
  69.  
  70.     s = 0
  71.     #s = smtplib.SMTP_SSL("smtp.gmail.com", 465)
  72.     #s.login("t5j6p9@gmail.com", "dpwzbydqcdqxhqfn")
  73.  
  74.     for i in oato(x):
  75.         print(tuple(map(lambda x: x.name, i)))
  76.         #santa_mail(s, *i)
  77.  
  78.     #s.quit()
  79.  
  80.  
  81. if __name__ == "__main__":
  82.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement