##// END OF EJS Templates
Fix exception handler syntax for Python 3 compatibility....
Daniel B. Vasquez -
Show More
@@ -38,7 +38,7 b' class PandocMissing(ConversionException):'
38 38 "Please check that pandoc is installed:\n" +
39 39 "http://johnmacfarlane.net/pandoc/installing.html" )
40 40
41 def pandoc_available(failmode="return", warn=False):
41 def pandoc_available(failmode="return", warn=False, alt=None):
42 42 """Is pandoc available. Only tries to call Pandoc
43 43 and inform you that it succeeded or failed.
44 44
@@ -50,6 +50,8 b' def pandoc_available(failmode="return", warn=False):'
50 50 the exception returned by subprocess.check_call.
51 51 - warn : bool
52 52 issue a user warning if pandoc is not available.
53 - alt: list of strings
54 command to print in the error (not used as actual call)
53 55
54 56 Return
55 57 ------
@@ -63,10 +65,10 b' def pandoc_available(failmode="return", warn=False):'
63 65 try:
64 66 out = subprocess.check_output(cmd, universal_newlines=True)
65 67 return True, None
66 except OSError, e:
68 except OSError as e:
67 69 if warn:
68 70 warnings.warn(
69 "Pandoc cannot be found (call %s failed).\n" % " ".join(cmd) +
71 "Pandoc cannot be found (calling %s failed).\n" % " ".join(alt or cmd) +
70 72 "Please check that pandoc is installed:\n" +
71 73 "http://johnmacfarlane.net/pandoc/installing.html"
72 74 )
@@ -74,7 +76,7 b' def pandoc_available(failmode="return", warn=False):'
74 76 if failmode == "return":
75 77 return False, e
76 78 else:
77 raise PandocMissing(cmd, e)
79 raise PandocMissing(alt or cmd, e)
78 80
79 81
80 82 #-----------------------------------------------------------------------------
@@ -109,7 +111,7 b" def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'):"
109 111 cmd.extend(extra_args)
110 112
111 113 # if pandoc is missing let the exception bubble us out of here
112 pandoc_available(failmode="raise")
114 pandoc_available(failmode="raise", alt=cmd)
113 115
114 116 # we can safely continue
115 117 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
General Comments 0
You need to be logged in to leave comments. Login now