Mercurial > libervia-backend
comparison frontends/src/jp/output_template.py @ 2348:18d71226b3a8
jp (output/template): check if there is a template before initializing Renderer
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 24 Aug 2017 01:11:47 +0200 |
parents | a81261cee29b |
children | 8b37a62336c3 |
comparison
equal
deleted
inserted
replaced
2347:b6dee1f66478 | 2348:18d71226b3a8 |
---|---|
46 @param data(dict): data is a dict which map from variable name to use in template | 46 @param data(dict): data is a dict which map from variable name to use in template |
47 to the variable itself. | 47 to the variable itself. |
48 command's template_data_mapping attribute will be used if it exists to convert | 48 command's template_data_mapping attribute will be used if it exists to convert |
49 data to a dict usable by the template. | 49 data to a dict usable by the template. |
50 """ | 50 """ |
51 self.renderer = template.Renderer(self.host) | |
52 cmd = self.host.command | 51 cmd = self.host.command |
53 options = self.host.parse_output_options() | |
54 self.host.check_output_options(OPTIONS, options) | |
55 try: | 52 try: |
56 template_path = cmd.TEMPLATE | 53 template_path = cmd.TEMPLATE |
57 except AttributeError: | 54 except AttributeError: |
58 if not 'template' in cmd.args.output_opts: | 55 if not 'template' in cmd.args.output_opts: |
59 self.host.disp(u'no default template set for this command, ' | 56 self.host.disp(u'no default template set for this command, ' |
60 u'you need to specify a template using --oo template=[path/to/template.html', | 57 u'you need to specify a template using --oo template=[path/to/template.html]', |
61 error=True) | 58 error=True) |
62 self.host.quit(C.EXIT_BAD_ARG) | 59 self.host.quit(C.EXIT_BAD_ARG) |
60 | |
61 options = self.host.parse_output_options() | |
62 self.host.check_output_options(OPTIONS, options) | |
63 self.renderer = template.Renderer(self.host) | |
63 try: | 64 try: |
64 template_path = options['template'] | 65 template_path = options['template'] |
65 except KeyError: | 66 except KeyError: |
66 # template is not specified, we use default one | 67 # template is not specified, we use default one |
67 pass | 68 pass |