diff frontends/src/jp/output_template.py @ 2187:4ec72927a222

jp (outputs): moved output options parsing and checking to base methods
author Goffi <goffi@goffi.org>
date Sun, 12 Mar 2017 23:31:06 +0100
parents f472179305a1
children a81261cee29b
line wrap: on
line diff
--- a/frontends/src/jp/output_template.py	Sun Mar 12 23:29:09 2017 +0100
+++ b/frontends/src/jp/output_template.py	Sun Mar 12 23:31:06 2017 +0100
@@ -39,16 +39,6 @@
         jp.register_output(C.OUTPUT_COMPLEX, TEMPLATE, self.render)
         self.renderer = template.Renderer(jp)
 
-    def parse_options(self, options):
-        options_dict = {}
-        for option in options:
-            try:
-                key, value = option.split(u'=', 1)
-            except ValueError:
-                key, value = option, None
-            options_dict[key.strip()] = value.strip() if value is not None else None
-        return options_dict
-
     def render(self, data):
         """render output data using requested template
 
@@ -60,12 +50,8 @@
             data to a dict usable by the template.
         """
         cmd = self.host.command
-        options = self.parse_options(cmd.args.output_opts)
-        if not OPTIONS.issuperset(options):
-            self.host.disp(u"The following output options are invalid: {invalid_options}".format(
-                invalid_options = u', '.join(set(options).difference(OPTIONS))),
-                error=True)
-            self.host.quit(C.EXIT_BAD_ARG)
+        options = self.host.parse_output_options()
+        self.host.check_output_options(OPTIONS, options)
         try:
             template_path = cmd.TEMPLATE
         except AttributeError: