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

Side by Side Diff: sitescripts/utils.py

Issue 29569566: Noissue - Replace flake8-putty with flake8-per-file-ignores, update to flake8 3 (sitescripts) (Closed)
Patch Set: Created Oct. 8, 2017, 6:02 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/urlfixer/bin/topDomains.py ('k') | sitescripts/web.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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 match = re.search(r'^([^@\s]+)@([^@\s]+)$', email) 135 match = re.search(r'^([^@\s]+)@([^@\s]+)$', email)
136 if not match: 136 if not match:
137 raise ValueError 137 raise ValueError
138 138
139 try: 139 try:
140 return email.encode('ascii') 140 return email.encode('ascii')
141 except UnicodeEncodeError: 141 except UnicodeEncodeError:
142 return '%s@%s' % (match.group(1).encode('ascii'), 142 return '%s@%s' % (match.group(1).encode('ascii'),
143 match.group(2).encode('idna')) 143 match.group(2).encode('idna'))
144 144
145
145 _template_cache = {} 146 _template_cache = {}
146 147
147 148
148 def get_template(template, autoescape=True, template_path=siteScriptsPath): 149 def get_template(template, autoescape=True, template_path=siteScriptsPath):
149 """Load Jinja2 template. 150 """Load Jinja2 template.
150 151
151 If `template` is a relative path, it's looked up inside `template_path`. 152 If `template` is a relative path, it's looked up inside `template_path`.
152 If it's an absolute path, `template_path` is not used. 153 If it's an absolute path, `template_path` is not used.
153 154
154 Note: Each template will only be loaded once (when first requested). After 155 Note: Each template will only be loaded once (when first requested). After
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Returns a custom Jinja2 template environment with additional filters. 200 Returns a custom Jinja2 template environment with additional filters.
200 """ 201 """
201 from sitescripts.templateFilters import filters 202 from sitescripts.templateFilters import filters
202 import jinja2 203 import jinja2
203 if not loader: 204 if not loader:
204 loader = jinja2.FileSystemLoader(siteScriptsPath) 205 loader = jinja2.FileSystemLoader(siteScriptsPath)
205 env = jinja2.Environment(loader=loader, autoescape=True) 206 env = jinja2.Environment(loader=loader, autoescape=True)
206 env.filters.update(filters) 207 env.filters.update(filters)
207 env.filters.update(additional_filters) 208 env.filters.update(additional_filters)
208 return env 209 return env
OLDNEW
« no previous file with comments | « sitescripts/urlfixer/bin/topDomains.py ('k') | sitescripts/web.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld