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

Side by Side Diff: sitescripts/utils.py

Issue 4790980679041024: Issue 2268 - Deprecate setupStderr() (Closed)
Patch Set: Created April 9, 2015, 8:35 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/__init__.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 config = SafeConfigParser() 75 config = SafeConfigParser()
76 config.optionxform = lambda x: x 76 config.optionxform = lambda x: x
77 config.read(path) 77 config.read(path)
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. 85 the stream passed in if any. DEPRECATED
86 """ 86 """
87 import warnings
88 warnings.warn('setupStderr() is deprecated, when directly '
89 'writing to stderr is problematic use the '
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)
91
87 sys.stderr = codecs.getwriter('utf8')(stream) 92 sys.stderr = codecs.getwriter('utf8')(stream)
88 93
89 def anonymizeMail(email): 94 def anonymizeMail(email):
90 """ 95 """
91 Anonymizes email to look like a**.n***@g****.c** 96 Anonymizes email to look like a**.n***@g****.c**
92 """ 97 """
93 return re.sub(r'(?<=[^.@])[^.@]', '*', email) 98 return re.sub(r'(?<=[^.@])[^.@]', '*', email)
94 99
95 def sendMail(template, data): 100 def sendMail(template, data):
96 """ 101 """
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Returns a custom Jinja2 template environment with additional filters. 154 Returns a custom Jinja2 template environment with additional filters.
150 """ 155 """
151 from sitescripts.templateFilters import filters 156 from sitescripts.templateFilters import filters
152 import jinja2 157 import jinja2
153 if not loader: 158 if not loader:
154 loader = jinja2.FileSystemLoader(siteScriptsPath) 159 loader = jinja2.FileSystemLoader(siteScriptsPath)
155 env = jinja2.Environment(loader=loader, autoescape=True) 160 env = jinja2.Environment(loader=loader, autoescape=True)
156 env.filters.update(filters) 161 env.filters.update(filters)
157 env.filters.update(additional_filters) 162 env.filters.update(additional_filters)
158 return env 163 return env
OLDNEW
« no previous file with comments | « sitescripts/__init__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld