[gsoc-admin] email: Don't execute code on module import



commit d6031fa72e6fbd645388ef805d519923a082aa7c
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date:   Wed Aug 12 14:42:59 2015 +0200

    email: Don't execute code on module import

 maillib/email.py |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/maillib/email.py b/maillib/email.py
index 06f41d9..56dc6fd 100755
--- a/maillib/email.py
+++ b/maillib/email.py
@@ -33,8 +33,9 @@ class EmailTemplate:
             send_mail(self.get_specific(data_dict), recipient.pretty_email_name())
 
 
-template_file = open('../data/templates/foo')
-template_text = template_file.read()
-template = EmailTemplate(template_text, None)
-format_dict = {'student_name': 'Rupert Monkey'}
-print(template.get_specific(format_dict))
+if __name__ == '__main__':
+    template_file = open('../data/templates/foo')
+    template_text = template_file.read()
+    template = EmailTemplate(template_text, None)
+    format_dict = {'student_name': 'Rupert Monkey'}
+    print(template.get_specific(format_dict))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]