diff frontends/src/jp/base.py @ 1872:df1ca137b0cb

jp (blog/edit): editor arguments can now be specified on sat.conf, and default on are applied for known editors: - vim and gvim will open content and metadata file in a splitted window - gvim use --nofork option - installed a workaround for shlex.split not handling unicode before Python 2.7.3 - some fixes
author Goffi <goffi@goffi.org>
date Thu, 03 Mar 2016 15:57:06 +0100
parents 9d9d61d53684
children 0fe69871b71f
line wrap: on
line diff
--- a/frontends/src/jp/base.py	Wed Mar 02 19:53:53 2016 +0100
+++ b/frontends/src/jp/base.py	Thu Mar 03 15:57:06 2016 +0100
@@ -38,6 +38,15 @@
 import sat_frontends.jp
 from sat_frontends.jp.constants import Const as C
 import xml.etree.ElementTree as ET  # FIXME: used temporarily to manage XMLUI
+import shlex
+
+if sys.version_info < (2, 7, 3):
+    # XXX: shlex.split only handle unicode since python 2.7.3
+    # this is a workaround for older versions
+    old_split = shlex.split
+    new_split = (lambda s, *a, **kw: [t.decode('utf-8') for t in old_split(s.encode('utf-8'), *a, **kw)]
+        if isinstance(s, unicode) else old_split(s, *a, **kw))
+    shlex.split = new_split
 
 try:
     import progressbar