|
@@ -202,29 +202,33 @@ open('%s', 'w').write( pprint.pformat(main()) )")
|
|
|
If RESULT-TYPE equals 'output then return standard output as a
|
|
|
string. If RESULT-TYPE equals 'value then return the value of the
|
|
|
last statement in BODY, as elisp."
|
|
|
- (case result-type
|
|
|
- (output (org-babel-eval org-babel-python-command
|
|
|
- (concat (if preamble (concat preamble "\n") "") body)))
|
|
|
- (value (let ((tmp-file (org-babel-temp-file "python-")))
|
|
|
- (org-babel-eval org-babel-python-command
|
|
|
- (concat
|
|
|
- (if preamble (concat preamble "\n") "")
|
|
|
- (format
|
|
|
- (if (member "pp" result-params)
|
|
|
- org-babel-python-pp-wrapper-method
|
|
|
- org-babel-python-wrapper-method)
|
|
|
- (mapconcat
|
|
|
- (lambda (line) (format "\t%s" line))
|
|
|
- (split-string
|
|
|
- (org-remove-indentation
|
|
|
- (org-babel-trim body))
|
|
|
- "[\r\n]") "\n")
|
|
|
- (org-babel-process-file-name tmp-file 'noquote))))
|
|
|
- ((lambda (raw)
|
|
|
- (if (or (member "code" result-params)
|
|
|
- (member "pp" result-params))
|
|
|
- raw
|
|
|
- (org-babel-python-table-or-string raw)))
|
|
|
+ ((lambda (raw)
|
|
|
+ (if (or (member "code" result-params)
|
|
|
+ (member "pp" result-params)
|
|
|
+ (and (member "output" result-params)
|
|
|
+ (not (member "table" result-params))))
|
|
|
+ raw
|
|
|
+ (org-babel-python-table-or-string (org-babel-trim raw))))
|
|
|
+ (case result-type
|
|
|
+ (output (org-babel-eval org-babel-python-command
|
|
|
+ (concat (if preamble (concat preamble "\n") "")
|
|
|
+ body)))
|
|
|
+ (value (let ((tmp-file (org-babel-temp-file "python-")))
|
|
|
+ (org-babel-eval
|
|
|
+ org-babel-python-command
|
|
|
+ (concat
|
|
|
+ (if preamble (concat preamble "\n") "")
|
|
|
+ (format
|
|
|
+ (if (member "pp" result-params)
|
|
|
+ org-babel-python-pp-wrapper-method
|
|
|
+ org-babel-python-wrapper-method)
|
|
|
+ (mapconcat
|
|
|
+ (lambda (line) (format "\t%s" line))
|
|
|
+ (split-string
|
|
|
+ (org-remove-indentation
|
|
|
+ (org-babel-trim body))
|
|
|
+ "[\r\n]") "\n")
|
|
|
+ (org-babel-process-file-name tmp-file 'noquote))))
|
|
|
(org-babel-eval-read-file tmp-file))))))
|
|
|
|
|
|
(defun org-babel-python-evaluate-session
|
|
@@ -248,22 +252,25 @@ last statement in BODY, as elisp."
|
|
|
(mapc (lambda (statement) (insert statement) (comint-send-input))
|
|
|
(split-string (org-babel-trim body) "[\r\n]+"))
|
|
|
(comint-send-input) (comint-send-input)))
|
|
|
- (case result-type
|
|
|
- (output
|
|
|
- (mapconcat
|
|
|
- #'org-babel-trim
|
|
|
- (butlast
|
|
|
- (org-babel-comint-with-output
|
|
|
- (session org-babel-python-eoe-indicator t body)
|
|
|
- (let ((comint-process-echoes nil))
|
|
|
- (input-body body)
|
|
|
- (insert org-babel-python-eoe-indicator)
|
|
|
- (comint-send-input))) 2) "\n"))
|
|
|
- (value
|
|
|
- ((lambda (results)
|
|
|
- (if (or (member "code" result-params) (member "pp" result-params))
|
|
|
- results
|
|
|
- (org-babel-python-table-or-string results)))
|
|
|
+ ((lambda (results)
|
|
|
+ (if (or (member "code" result-params)
|
|
|
+ (member "pp" result-params)
|
|
|
+ (and (member "output" result-params)
|
|
|
+ (not (member "table" result-params))))
|
|
|
+ results
|
|
|
+ (org-babel-python-table-or-string results)))
|
|
|
+ (case result-type
|
|
|
+ (output
|
|
|
+ (mapconcat
|
|
|
+ #'org-babel-trim
|
|
|
+ (butlast
|
|
|
+ (org-babel-comint-with-output
|
|
|
+ (session org-babel-python-eoe-indicator t body)
|
|
|
+ (let ((comint-process-echoes nil))
|
|
|
+ (input-body body)
|
|
|
+ (insert org-babel-python-eoe-indicator)
|
|
|
+ (comint-send-input))) 2) "\n"))
|
|
|
+ (value
|
|
|
(let ((tmp-file (org-babel-temp-file "python-")))
|
|
|
(org-babel-comint-with-output
|
|
|
(session org-babel-python-eoe-indicator nil body)
|