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

Delta Between Two Patch Sets: sitescripts/utils.py

Issue 4790980679041024: Issue 2268 - Deprecate setupStderr() (Closed)
Left Patch Set: Created April 9, 2015, 8:35 p.m.
Right Patch Set: Improved warning text Created April 9, 2015, 9:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/__init__.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return config 78 return config
79 79
80 raise Exception('No config file found. Please put sitescripts.ini into your ho me directory or /etc') 80 raise Exception('No config file found. Please put sitescripts.ini into your ho me directory or /etc')
81 81
82 def setupStderr(stream=sys.stderr): 82 def setupStderr(stream=sys.stderr):
83 """ 83 """
84 Sets up sys.stderr to accept Unicode characters, redirects error output to 84 Sets up sys.stderr to accept Unicode characters, redirects error output to
85 the stream passed in if any. DEPRECATED 85 the stream passed in if any. DEPRECATED
86 """ 86 """
87 import warnings 87 import warnings
88 warnings.warn('setupStderr() is deprecated, when directly ' 88 warnings.warn('setupStderr() is deprecated. If you write '
89 'writing to stderr is problematic use the ' 89 'text to stderr that might be non-ASCII use '
Wladimir Palant 2015/04/09 21:09:03 Maybe a more clear explanation of the issue? 'setu
Sebastian Noack 2015/04/09 21:19:05 Done, but replaced "data" with "text".
90 '"logging" module instead', DeprecationWarning, 2) 90 'the "logging" module instead.', DeprecationWarning, 2)
91 91
92 sys.stderr = codecs.getwriter('utf8')(stream) 92 sys.stderr = codecs.getwriter('utf8')(stream)
93 93
94 def anonymizeMail(email): 94 def anonymizeMail(email):
95 """ 95 """
96 Anonymizes email to look like a**.n***@g****.c** 96 Anonymizes email to look like a**.n***@g****.c**
97 """ 97 """
98 return re.sub(r'(?<=[^.@])[^.@]', '*', email) 98 return re.sub(r'(?<=[^.@])[^.@]', '*', email)
99 99
100 def sendMail(template, data): 100 def sendMail(template, data):
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 Returns a custom Jinja2 template environment with additional filters. 154 Returns a custom Jinja2 template environment with additional filters.
155 """ 155 """
156 from sitescripts.templateFilters import filters 156 from sitescripts.templateFilters import filters
157 import jinja2 157 import jinja2
158 if not loader: 158 if not loader:
159 loader = jinja2.FileSystemLoader(siteScriptsPath) 159 loader = jinja2.FileSystemLoader(siteScriptsPath)
160 env = jinja2.Environment(loader=loader, autoescape=True) 160 env = jinja2.Environment(loader=loader, autoescape=True)
161 env.filters.update(filters) 161 env.filters.update(filters)
162 env.filters.update(additional_filters) 162 env.filters.update(additional_filters)
163 return env 163 return env
LEFTRIGHT

Powered by Google App Engine
This is Rietveld