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

Delta Between Two Patch Sets: cms/utils.py

Issue 29328208: Noissue - [CMS] Avoid overzealous catching of KeyError during conversion (Closed)
Left Patch Set: Created Sept. 21, 2015, 9:16 a.m.
Right Patch Set: Gave converter_class variable a better name Created Sept. 21, 2015, 11:20 a.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 | « no previous file | no next file » | 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-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 if format in converters: 51 try:
52 converter = converters[format](params) 52 converter_class = converters[format]
53 else: 53 except KeyError:
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
56 converter = converter_class(params)
55 57
56 # Note: The converter might change some parameters so we can only read in 58 # Note: The converter might change some parameters so we can only read in
57 # template data here. 59 # template data here.
58 params["templatedata"] = source.read_template(params["template"]) 60 params["templatedata"] = source.read_template(params["template"])
59 61
60 defaultlocale = params["config"].get("general", "defaultlocale") 62 defaultlocale = params["config"].get("general", "defaultlocale")
61 params["defaultlocale"] = defaultlocale 63 params["defaultlocale"] = defaultlocale
62 64
63 locales = [ 65 locales = [
64 l 66 l
(...skipping 14 matching lines...) Expand all
79 81
80 return params 82 return params
81 83
82 def process_page(source, locale, page, format=None, site_url_override=None, 84 def process_page(source, locale, page, format=None, site_url_override=None,
83 localized_string_callback=None): 85 localized_string_callback=None):
84 return TemplateConverter( 86 return TemplateConverter(
85 get_page_params(source, locale, page, format, 87 get_page_params(source, locale, page, format,
86 site_url_override, localized_string_callback), 88 site_url_override, localized_string_callback),
87 key="templatedata" 89 key="templatedata"
88 )() 90 )()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld