OLD | NEW |
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 Loading... |
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. If you write ' |
| 89 'text to stderr that might be non-ASCII use ' |
| 90 'the "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 Loading... |
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 |
OLD | NEW |