Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/utils.py

Issue 29670611: Issue 5844 - Remove redundant parentheses in sitescripts and abpsembly (Closed) Base URL: https://hg.adblockplus.org/sitescripts/
Patch Set: Created Jan. 16, 2018, 5:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 108
109 def sendMail(template, data): 109 def sendMail(template, data):
110 """ 110 """
111 Sends a mail generated from the template and data given. 111 Sends a mail generated from the template and data given.
112 """ 112 """
113 template = get_template(template, False) 113 template = get_template(template, False)
114 mail = template.render(data) 114 mail = template.render(data)
115 config = get_config() 115 config = get_config()
116 if config.has_option('DEFAULT', 'mailerDebug') and config.get('DEFAULT', 'ma ilerDebug') == 'yes': 116 if config.has_option('DEFAULT', 'mailerDebug') and config.get('DEFAULT', 'ma ilerDebug') == 'yes':
117 (handle, path) = mkstemp(prefix='mail_', suffix='.eml', dir='.') 117 handle, path = mkstemp(prefix='mail_', suffix='.eml', dir='.')
118 os.close(handle) 118 os.close(handle)
119 f = codecs.open(path, 'wb', encoding='utf-8') 119 f = codecs.open(path, 'wb', encoding='utf-8')
120 print >>f, mail 120 print >>f, mail
121 f.close() 121 f.close()
122 else: 122 else:
123 subprocess.Popen([config.get('DEFAULT', 'mailer'), '-t'], stdin=subproce ss.PIPE).communicate(mail.encode('utf-8')) 123 subprocess.Popen([config.get('DEFAULT', 'mailer'), '-t'], stdin=subproce ss.PIPE).communicate(mail.encode('utf-8'))
124 124
125 125
126 def encode_email_address(email): 126 def encode_email_address(email):
127 """ 127 """
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 Returns a custom Jinja2 template environment with additional filters. 200 Returns a custom Jinja2 template environment with additional filters.
201 """ 201 """
202 from sitescripts.templateFilters import filters 202 from sitescripts.templateFilters import filters
203 import jinja2 203 import jinja2
204 if not loader: 204 if not loader:
205 loader = jinja2.FileSystemLoader(siteScriptsPath) 205 loader = jinja2.FileSystemLoader(siteScriptsPath)
206 env = jinja2.Environment(loader=loader, autoescape=True) 206 env = jinja2.Environment(loader=loader, autoescape=True)
207 env.filters.update(filters) 207 env.filters.update(filters)
208 env.filters.update(additional_filters) 208 env.filters.update(additional_filters)
209 return env 209 return env
OLDNEW
« sitescripts/templateFilters.py ('K') | « sitescripts/urlfixer/web/submitData.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld