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

Side by Side Diff: sitescripts/formmail/web/formmail2.py

Issue 29756646: Noissue - Adapt best practices for trailing commas (abpssembly) (Closed)
Patch Set: Re-run script on Python 2, added flake8-commas extension Created April 19, 2018, 2:41 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
« no previous file with comments | « sitescripts/formmail/test/test_formmail.py ('k') | sitescripts/hg/bin/update_issues.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 @form_handler 138 @form_handler
139 def handler(environ, start_response, params): 139 def handler(environ, start_response, params):
140 response_headers = [('Content-Type', 'text/plain; charset=utf-8')] 140 response_headers = [('Content-Type', 'text/plain; charset=utf-8')]
141 errors = validate_fields(fields, params) 141 errors = validate_fields(fields, params)
142 if errors: 142 if errors:
143 start_response('400 Bad Request', response_headers) 143 start_response('400 Bad Request', response_headers)
144 return '\n'.join(errors) 144 return '\n'.join(errors)
145 time = datetime.datetime.now() 145 time = datetime.datetime.now()
146 template_args = { 146 template_args = {
147 'time': time, 147 'time': time,
148 'fields': {field: params.get(field, '') for field in fields} 148 'fields': {field: params.get(field, '') for field in fields},
149 } 149 }
150 try: 150 try:
151 sendMail(template, template_args) 151 sendMail(template, template_args)
152 except: 152 except:
153 print(traceback.print_exc(), file=sys.stderr) 153 print(traceback.print_exc(), file=sys.stderr)
154 start_response('500 Server Error', response_headers) 154 start_response('500 Server Error', response_headers)
155 return '' 155 return ''
156 finally: 156 finally:
157 if 'csv_log' in config: 157 if 'csv_log' in config:
158 params = {field: params.get(field, '').encode('utf8') 158 params = {field: params.get(field, '').encode('utf8')
159 for field in fields} 159 for field in fields}
160 params['time'] = time 160 params['time'] = time
161 log_formdata(params, config['csv_log'].value) 161 log_formdata(params, config['csv_log'].value)
162 start_response('200 OK', response_headers) 162 start_response('200 OK', response_headers)
163 return '' 163 return ''
164 164
165 return url, handler 165 return url, handler
166 166
167 167
168 conf_dict = conf_parse(get_config_items()) 168 conf_dict = conf_parse(get_config_items())
169 for name, config in conf_dict.items(): 169 for name, config in conf_dict.items():
170 url, handler = make_handler(name, config) 170 url, handler = make_handler(name, config)
171 registerUrlHandler(url, handler) 171 registerUrlHandler(url, handler)
OLDNEW
« no previous file with comments | « sitescripts/formmail/test/test_formmail.py ('k') | sitescripts/hg/bin/update_issues.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld