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

Delta Between Two Patch Sets: sitescripts/utils.py

Issue 5744805892063232: Issue 1374 - Don`t hardcode web handlers for multiplexer (Closed)
Left Patch Set: Created Sept. 15, 2014, 9:58 a.m.
Right Patch Set: Changed option name transformation Created Sept. 18, 2014, 7:11 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.example ('k') | sitescripts/web.py » ('j') | 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-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
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 = str 76 config.optionxform = lambda x: x
Sebastian Noack 2014/09/18 16:05:37 Why is this necessary? Won't that break for option
Wladimir Palant 2014/09/18 18:04:14 By default, SafeConfigParser will lower-case all o
Sebastian Noack 2014/09/18 19:01:07 How about a simple no-op? config.optionxform = la
Wladimir Palant 2014/09/18 19:12:22 Sounds like a good compromise. This will allow usi
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.
86 """ 86 """
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Returns a custom Jinja2 template environment with additional filters. 149 Returns a custom Jinja2 template environment with additional filters.
150 """ 150 """
151 from sitescripts.templateFilters import filters 151 from sitescripts.templateFilters import filters
152 import jinja2 152 import jinja2
153 if not loader: 153 if not loader:
154 loader = jinja2.FileSystemLoader(siteScriptsPath) 154 loader = jinja2.FileSystemLoader(siteScriptsPath)
155 env = jinja2.Environment(loader=loader, autoescape=True) 155 env = jinja2.Environment(loader=loader, autoescape=True)
156 env.filters.update(filters) 156 env.filters.update(filters)
157 env.filters.update(additional_filters) 157 env.filters.update(additional_filters)
158 return env 158 return env
LEFTRIGHT

Powered by Google App Engine
This is Rietveld