diff frontends/src/jp/cmd_blog.py @ 2273:5f0dbf42aa9c

jp (blog, common): various fixes in common and blog: - parse_args has been moved to common - cat_dir is converted to str on BaseEdit init, so it can be use to make str path for files manipulation - fixed use of EDITOR_ARGS_MAGIC when use_metadata is False - fixed unlink of metadata files when use_metadata is False
author Goffi <goffi@goffi.org>
date Tue, 27 Jun 2017 19:38:22 +0200
parents 2fae89f30b8d
children 4bc9a2c2d6c9
line wrap: on
line diff
--- a/frontends/src/jp/cmd_blog.py	Tue Jun 27 19:38:20 2017 +0200
+++ b/frontends/src/jp/cmd_blog.py	Tue Jun 27 19:38:22 2017 +0200
@@ -33,7 +33,6 @@
 import time
 import tempfile
 import subprocess
-import shlex
 from sat.tools.common import data_format
 
 __commands__ = ["Blog"]
@@ -47,7 +46,7 @@
 
 
 CONF_SYNTAX_EXT = 'syntax_ext_dict'
-BLOG_TMP_DIR=u"blog"
+BLOG_TMP_DIR = u"blog"
 # key to remove from metadata tmp file if they exist
 KEY_TO_REMOVE_METADATA = ('id','content', 'content_xhtml', 'comments_node', 'comments_service', 'updated')
 
@@ -97,21 +96,6 @@
         # if not found, we use current syntax
         return self.host.bridge.getParamA("Syntax", "Composition", "value", self.profile)
 
-    def parse_args(self, cmd_line, **format_kw):
-        """Parse command arguments
-
-        @param cmd_line(unicode): command line as found in sat.conf
-        @param format_kw: keywords used for formmating
-        @return (list(unicode)): list of arguments to pass to subprocess function
-        """
-        try:
-            # we split the arguments and add the known fields
-            # we split arguments first to avoid escaping issues in file names
-            return [a.format(**format_kw) for a in shlex.split(cmd_line)]
-        except ValueError as e:
-            self.disp(u"Couldn't parse editor cmd [{cmd}]: {reason}".format(cmd=cmd_line, reason=e))
-            return []
-
 
 class Get(base.CommandBase, BlogCommon):
     TEMPLATE = u"blog/articles.html"
@@ -423,7 +407,7 @@
 
     def _launchPreviewExt(self, cmd_line, opt_name):
         url = 'file:{}'.format(self.urllib.quote(self.preview_file_path))
-        args = self.parse_args(cmd_line, url=url, preview_file=self.preview_file_path)
+        args = common.parse_args(self.host, cmd_line, url=url, preview_file=self.preview_file_path)
         if not args:
             self.disp(u"Couln't find command in \"{name}\", abording".format(name=opt_name), error=True)
             self.host.quit(1)