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-2014 Eyeo GmbH | 4 # Copyright (C) 2006-2014 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 paths.append(os.path.expanduser('~/sitescripts.ini')) | 66 paths.append(os.path.expanduser('~/sitescripts.ini')) |
67 | 67 |
68 # Server-wide configuration if no custom found | 68 # Server-wide configuration if no custom found |
69 paths.append('/etc/sitescripts') | 69 paths.append('/etc/sitescripts') |
70 paths.append('/etc/sitescripts.ini') | 70 paths.append('/etc/sitescripts.ini') |
71 | 71 |
72 for path in paths: | 72 for path in paths: |
73 path = os.path.abspath(path) | 73 path = os.path.abspath(path) |
74 if os.path.exists(path): | 74 if os.path.exists(path): |
75 config = SafeConfigParser() | 75 config = SafeConfigParser() |
| 76 config.optionxform = lambda x: x |
76 config.read(path) | 77 config.read(path) |
77 return config | 78 return config |
78 | 79 |
79 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') |
80 | 81 |
81 def setupStderr(stream=sys.stderr): | 82 def setupStderr(stream=sys.stderr): |
82 """ | 83 """ |
83 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 |
84 the stream passed in if any. | 85 the stream passed in if any. |
85 """ | 86 """ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 Returns a custom Jinja2 template environment with additional filters. | 149 Returns a custom Jinja2 template environment with additional filters. |
149 """ | 150 """ |
150 from sitescripts.templateFilters import filters | 151 from sitescripts.templateFilters import filters |
151 import jinja2 | 152 import jinja2 |
152 if not loader: | 153 if not loader: |
153 loader = jinja2.FileSystemLoader(siteScriptsPath) | 154 loader = jinja2.FileSystemLoader(siteScriptsPath) |
154 env = jinja2.Environment(loader=loader, autoescape=True) | 155 env = jinja2.Environment(loader=loader, autoescape=True) |
155 env.filters.update(filters) | 156 env.filters.update(filters) |
156 env.filters.update(additional_filters) | 157 env.filters.update(additional_filters) |
157 return env | 158 return env |
OLD | NEW |