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: Go back to using try... catch Created Sept. 21, 2015, 11:03 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 try:
52 converter = converters[format] 52 converter_class = converters[format]
Wladimir Palant 2015/09/21 11:18:02 I think this variable is better called converter_c
kzar 2015/09/21 11:23:15 Done.
53 except KeyError: 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))
55 55
56 converter = converter(params) 56 converter = converter_class(params)
57 57
58 # 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
59 # template data here. 59 # template data here.
60 params["templatedata"] = source.read_template(params["template"]) 60 params["templatedata"] = source.read_template(params["template"])
61 61
62 defaultlocale = params["config"].get("general", "defaultlocale") 62 defaultlocale = params["config"].get("general", "defaultlocale")
63 params["defaultlocale"] = defaultlocale 63 params["defaultlocale"] = defaultlocale
64 64
65 locales = [ 65 locales = [
66 l 66 l
(...skipping 14 matching lines...) Expand all
81 81
82 return params 82 return params
83 83
84 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,
85 localized_string_callback=None): 85 localized_string_callback=None):
86 return TemplateConverter( 86 return TemplateConverter(
87 get_page_params(source, locale, page, format, 87 get_page_params(source, locale, page, format,
88 site_url_override, localized_string_callback), 88 site_url_override, localized_string_callback),
89 key="templatedata" 89 key="templatedata"
90 )() 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