mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-13 16:38:24 +00:00
org-babel-expand-body:python
This commit is contained in:
parent
598dc1ad67
commit
1bcafa5d9f
@ -36,23 +36,26 @@
|
||||
|
||||
(add-to-list 'org-babel-tangle-langs '("python" "py" "#!/usr/bin/env python"))
|
||||
|
||||
(defun org-babel-expand-body:python (body params &optional processed-params)
|
||||
(let (vars (second (or processed-params (org-babel-process-params params))))
|
||||
(concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-python-var-to-python (cdr pair))))
|
||||
vars "\n") "\n" (org-babel-trim body) "\n")))
|
||||
|
||||
(defun org-babel-execute:python (body params)
|
||||
"Execute a block of Python code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block'."
|
||||
(message "executing Python source code block")
|
||||
(let* ((processed-params (org-babel-process-params params))
|
||||
(session (org-babel-python-initiate-session (first processed-params)))
|
||||
(vars (second processed-params))
|
||||
(result-params (third processed-params))
|
||||
(result-type (fourth processed-params))
|
||||
(full-body (concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-python-var-to-python (cdr pair))))
|
||||
vars "\n") "\n" (org-babel-trim body) "\n")) ;; then the source block body
|
||||
|
||||
(full-body (org-babel-expand-body:python
|
||||
body params processed-params)) ;; then the source block body
|
||||
(result (org-babel-python-evaluate session full-body result-type)))
|
||||
(or (cdr (assoc :file params))
|
||||
(org-babel-reassemble-table
|
||||
|
Loading…
Reference in New Issue
Block a user