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

Side by Side Diff: cms/utils.py

Issue 29328208: Noissue - [CMS] Avoid overzealous catching of KeyError during conversion (Closed)
Patch Set: Created Sept. 21, 2015, 9:16 a.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 | « no previous file | 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 30 matching lines...) Expand all
41 if params["config"].has_option("locale_overrides", page): 41 if params["config"].has_option("locale_overrides", page):
42 localefile = params["config"].get("locale_overrides", page) 42 localefile = params["config"].get("locale_overrides", page)
43 params["localedata"] = source.read_locale(params["locale"], localefile) 43 params["localedata"] = source.read_locale(params["locale"], localefile)
44 44
45 if params["config"].has_option("general", "siteurl"): 45 if params["config"].has_option("general", "siteurl"):
46 if site_url_override: 46 if site_url_override:
47 params["site_url"] = site_url_override 47 params["site_url"] = site_url_override
48 else: 48 else:
49 params["site_url"] = params["config"].get("general", "siteurl") 49 params["site_url"] = params["config"].get("general", "siteurl")
50 50
51 try: 51 if format in converters:
52 converter = converters[format](params) 52 converter = converters[format](params)
53 except KeyError: 53 else:
54 raise Exception("Page %s uses unknown format %s" % (page, format)) 54 raise Exception("Page %s uses unknown format %s" % (page, format))
Wladimir Palant 2015/09/21 10:54:29 I think Sebastian will object to that approach :)
kzar 2015/09/21 11:06:22 Yea, I guessed it might have been unpopular. It se
55 55
56 # Note: The converter might change some parameters so we can only read in 56 # Note: The converter might change some parameters so we can only read in
57 # template data here. 57 # template data here.
58 params["templatedata"] = source.read_template(params["template"]) 58 params["templatedata"] = source.read_template(params["template"])
59 59
60 defaultlocale = params["config"].get("general", "defaultlocale") 60 defaultlocale = params["config"].get("general", "defaultlocale")
61 params["defaultlocale"] = defaultlocale 61 params["defaultlocale"] = defaultlocale
62 62
63 locales = [ 63 locales = [
64 l 64 l
(...skipping 14 matching lines...) Expand all
79 79
80 return params 80 return params
81 81
82 def process_page(source, locale, page, format=None, site_url_override=None, 82 def process_page(source, locale, page, format=None, site_url_override=None,
83 localized_string_callback=None): 83 localized_string_callback=None):
84 return TemplateConverter( 84 return TemplateConverter(
85 get_page_params(source, locale, page, format, 85 get_page_params(source, locale, page, format,
86 site_url_override, localized_string_callback), 86 site_url_override, localized_string_callback),
87 key="templatedata" 87 key="templatedata"
88 )() 88 )()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld