;ELC ;;; Compiled ;;; in Emacs version 26.3 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301!\210\300\302!\210\300\303!\210\304\305\306\"\207" [require ob org-macs python add-to-list org-babel-tangle-lang-exts ("python" . "py")] 3) (defvar org-babel-default-header-args:python nil) (byte-code "\300\301\302\303\304DD\305\306\307\310\311\312\313\314\315& \210\300\316\302\303\317DD\320\312\313\306\307\310\321\314\322& \210\300\323\302\303\324DD\325\312\313\306\307\310\326\314\315& \210\300\327\302\303\330DD\331\312\313\306\307\310\332\314\322& \207" [custom-declare-variable org-babel-python-command funcall function #[0 "\300\207" [#1="python"] 1 #1#] "Name of the command for executing Python code." :version "24.4" :package-version (Org . "8.0") :group org-babel :type string org-babel-python-mode #[0 "\300\301!\203\301\207\302\207" [featurep python-mode python] 2] "Preferred python mode for use in running python interactively.\nThis will typically be either `python' or `python-mode'." (Org . "8.0") symbol org-babel-python-hline-to #[0 "\300\207" [#2="None"] 1 #2#] "Replace hlines in incoming tables with this when translating to python." (Org . "8.0") org-babel-python-None-to #[0 "\300\207" [hline] 1] "Replace `None' in python tables with this before returning." (Org . "8.0")] 12) #@120 Execute a block of Python code with Babel. This function is called by `org-babel-execute-src-block'. (fn BODY PARAMS) (defalias 'org-babel-execute:python #[514 "\301\236A\206\302\303\236A!\304\236A\305\236A\211\306=\205&?\205&\307\236A\310\236A\311\2038\312\313\"\2029\314P\315 !#\316%\317\320\321 \236A\322\f\236A\"\320\323\f\236A\324 \236A\"#)\207" [org-babel-python-command :python org-babel-python-initiate-session :session :result-params :result-type value :return :preamble org-babel-expand-body:generic format "\nreturn %s" "" org-babel-variable-assignments:python org-babel-python-evaluate org-babel-reassemble-table org-babel-pick-name :colname-names :colnames :rowname-names :rownames] 16 (#$ . 1635)]) #@127 Prepare SESSION according to the header arguments in PARAMS. VARS contains resolved variable references. (fn SESSION PARAMS) (defalias 'org-babel-prep-session:python #[514 "\301!\302!\303!\204\304\305\"\210\306 \307\310\311\312\313!\314\"\315$\216rq\210\212\316\317\307\320\321\312\313!\322\"\315\323%\"\210,\210\207" [comint-input-filter org-babel-python-initiate-session org-babel-variable-assignments:python org-babel-comint-buffer-livep error "Buffer %s does not exist or has no process" match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 #[257 "\300\207" [nil] 2 "\n\n(fn INPUT)"] mapc 257 "\301\210\211c\210\302 \210\303\300!\207" [1 comint-send-input org-babel-comint-wait-for-output] "\n\n(fn VAR)"] 12 (#$ . 2392)]) #@51 Load BODY into SESSION. (fn SESSION BODY PARAMS) (defalias 'org-babel-load-session:python #[771 "\300 \301\302\303\304\305!\306\"\307$\216\310\"r\211q\210\311\312p!!b\210\313!c\210)\211\262)\207" [current-window-configuration make-byte-code 0 "\301\300!\207" vconcat vector [set-window-configuration] 2 org-babel-prep-session:python process-mark get-buffer-process org-babel-chomp] 10 (#$ . 3180)]) #@82 Return a list of Python statements assigning the block's variables. (fn PARAMS) (defalias 'org-babel-variable-assignments:python #[257 "\300\301\302!\"\207" [mapcar #[257 "\300\301@\302A!#\207" [format "%s=%s" org-babel-python-var-to-python] 6 "\n\n(fn PAIR)"] org-babel--get-vars] 5 (#$ . 3591)]) #@162 Convert an elisp value to a python variable. Convert an elisp value, VAR, into a string of python source code specifying a variable of the same value. (fn VAR) (defalias 'org-babel-python-var-to-python #[257 "\211<\203\301\302\303\304#\305Q\207\211\306=\203\207\307;\203'\310\311\"\203'\312\202(\313;\2033\314!\2024\"\207" [org-babel-python-hline-to "[" mapconcat org-babel-python-var-to-python ", " "]" hline format string-match "[\n ]" "\"\"%S\"\"" "%S" substring-no-properties] 6 (#$ . 3900)]) #@192 Convert RESULTS into an appropriate elisp value. If the results look like a list or tuple, then convert them into an Emacs-lisp table, otherwise return the results as a string. (fn RESULTS) (defalias 'org-babel-python-table-or-string #[257 "\300!\211<\203\301\302\"\202\211\207" [org-babel-script-escape mapcar #[257 "\211\301=\203\207\207" [org-babel-python-None-to None] 3 "\n\n(fn EL)"]] 5 (#$ . 4421)]) (defvar org-babel-python-buffers '((:default . "*Python*"))) #@58 Return the buffer associated with SESSION. (fn SESSION) (defalias 'org-babel-python-session-buffer #[257 "\301\"A\207" [org-babel-python-buffers assoc] 4 (#$ . 4905)]) #@16 (fn SESSION) (defalias 'org-babel-python-with-earmuffs #[257 "\211;\203 \211\202 \300\301\"\211\302\303O\304\230\203%\211GS\305O\304\230\203%\211\202)\300\306\"\207" [format "%s" 0 1 "*" nil "*%s*"] 5 (#$ . 5082)]) #@16 (fn SESSION) (defalias 'org-babel-python-without-earmuffs #[257 "\211;\203 \211\202 \300\301\"\211\302\303O\304\230\203*\211GS\305O\304\230\203*\211\303GSO\202+\211\207" [format "%s" 0 1 "*" nil] 5 (#$ . 5313)]) #@159 Initiate a python session. If there is not a current inferior-process-buffer in SESSION then create. Return the initialized session. (fn &optional SESSION) (defalias 'org-babel-python-initiate-session-by-key #[256 "\306 \307\310\311\312\313!\314\"\315$\216\203\316!\202\317\320!\321\235\203( \322P\202) \n\323=\203I\2048\324!\262\325!\326!\210\327\310\330\"\210)\202\222\n\331=\203\216\332\333!\203\216\334\331!\210\335\f!\210\203o\336!\203o\337\340\341#\202t\342\343!P\211\324!\262\333\344\211\345 \344\211\345\344& \210)\210\202\222\346\347!\210B\350)\"B)\266\203)\207" [system-type org-babel-python-command org-babel-python-mode python-shell-buffer-name py-default-interpreter py-which-bufname current-window-configuration make-byte-code 0 "\301\300!\207" vconcat vector [set-window-configuration] 2 intern :default org-babel-python-session-buffer (cygwin windows-nt ms-dos) " -i" python org-babel-python-with-earmuffs org-babel-python-without-earmuffs run-python sleep-for 10 python-mode fboundp py-shell require py-toggle-shells buffer-live-p replace-regexp-in-string "^\\*\\([^*]+\\)\\*$" "\\1" "Python-" symbol-name nil t error "No function available for running an inferior Python" assq-delete-all org-babel-python-buffers] 16 (#$ . 5542)]) #@84 Create a session named SESSION according to PARAMS. (fn &optional SESSION PARAMS) (defalias 'org-babel-python-initiate-session #[512 "\300\230?\205\f\301\302!!\207" ["none" org-babel-python-session-buffer org-babel-python-initiate-session-by-key] 5 (#$ . 6840)]) #@53 A string to indicate that evaluation has completed. (defvar org-babel-python-eoe-indicator "org_babel_python_eoe" (#$ . 7113)) (defconst org-babel-python-wrapper-method "\ndef main():\n%s\n\nopen('%s', 'w').write( str(main()) )") (defconst org-babel-python-pp-wrapper-method "\nimport pprint\ndef main():\n%s\n\nopen('%s', 'w').write( pprint.pformat(main()) )") #@136 Template for Python session command with output results. Has a single %s escape, the tempfile containing the source code to evaluate. (defconst org-babel-python--exec-tmpfile "with open('%s') as __org_babel_python_tmpfile:\n exec(compile(__org_babel_python_tmpfile.read(), __org_babel_python_tmpfile.name, 'exec'))" (#$ . 7482)) #@115 Return Python code to evaluate SRC-FILE and write result to RESULT-FILE. (fn SRC-FILE RESULT-FILE RESULT-PARAMS) (defalias 'org-babel-python-format-session-value #[771 "\300\301\302\303\"\302\303\"\304\235\203\305\202\306$\207" [format "import ast\nwith open('%s') as __org_babel_python_tmpfile:\n __org_babel_python_ast = ast.parse(__org_babel_python_tmpfile.read())\n__org_babel_python_final = __org_babel_python_ast.body[-1]\nif isinstance(__org_babel_python_final, ast.Expr):\n __org_babel_python_ast.body = __org_babel_python_ast.body[:-1]\n exec(compile(__org_babel_python_ast, '', 'exec'))\n __org_babel_python_final = eval(compile(ast.Expression(\n __org_babel_python_final.value), '', 'eval'))\n with open('%s', 'w') as __org_babel_python_tmpfile:\n if %s:\n import pprint\n __org_babel_python_tmpfile.write(pprint.pformat(__org_babel_python_final))\n else:\n __org_babel_python_tmpfile.write(str(__org_babel_python_final))\nelse:\n exec(compile(__org_babel_python_ast, '', 'exec'))\n __org_babel_python_final = None" org-babel-process-file-name noquote "pp" "True" "False"] 9 (#$ . 7822)]) #@95 Evaluate BODY as Python code. (fn SESSION BODY &optional RESULT-TYPE RESULT-PARAMS PREAMBLE) (defalias 'org-babel-python-evaluate #[1282 "\203 \300$\207\301$\207" [org-babel-python-evaluate-session org-babel-python-evaluate-external-process] 10 (#$ . 9035)]) #@29 (fn BODY &optional COUNT) (defalias 'org-babel-python--shift-right #[513 "\300\301!r\211q\210\302\303\304\305\306!\307\"\310$\216\311 \210c\210eb\210m\204>\312 \3138\205+\3148\262\2048\315\316 \317 #\210\320y\210\202\321 *\207" [generate-new-buffer " *temp*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 python-mode syntax-ppss 3 8 python-indent-shift-right line-beginning-position line-end-position 1 buffer-string] 9 (#$ . 9311)]) #@265 Evaluate BODY in external python process. 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. (fn BODY &optional RESULT-TYPE RESULT-PARAMS PREAMBLE) (defalias 'org-babel-python-evaluate-external-process #[1025 "\303=\203\304\211\205\305Q\"\202I\306=\203H\307\310!\304\211\205&\305\311\312\235\2032 \2023\n\313 !\314\315\"#Q\"\210\316!\262\202I\317\320\235?\205\257\321\235\204\223\322\235\204\223\323\235\204\223\324\235\204\223\312\235\204\223\325\235\204\223\326\235\204\215\327\235\204\215\330\235\204\215\331\235\203\227\332\235\204\227\202\257\333\317\334\203\243\335\202\244\336\337\334\340\337##\266\202!\262\207" [org-babel-python-command org-babel-python-pp-wrapper-method org-babel-python-wrapper-method output org-babel-eval "\n" value org-babel-temp-file "python-" format "pp" org-babel-python--shift-right org-babel-process-file-name noquote org-babel-eval-read-file nil "none" "scalar" "verbatim" "html" "code" "file" "output" "raw" "org" "drawer" "table" org-babel-python-table-or-string replace-regexp-in-string "\\`\\([ ]*\n\\)+" "\\`[ \n ]+" "" "[ \n ]+\\'"] 16 (#$ . 9810)]) #@79 Pass BODY to the Python process in SESSION. Return output. (fn SESSION BODY) (defalias 'org-babel-python--send-string #[514 "rq\210\304C\305\306\307\310\311!\312\"\313\314%B\315\316\317\313\" #\n\320=\204/\321!\322!\210)\202;\323\320!\210\324\325!\"\210\326 \242\"\204L\327\325p!!\210\202;\330\242\331\211\224O!)\266\202)\207" [comint-output-filter-functions org-babel-python-eoe-indicator org-babel-python-mode python-shell-buffer-name "" make-byte-code 257 "\300\211\242P\240\207" vconcat vector [] 4 "\n\n(fn TEXT)" format "try:\n%s\nexcept:\n raise\nfinally:\n print('%s')" org-babel-python--shift-right python-mode org-babel-python-without-earmuffs python-shell-send-string require py-shell-send-string get-buffer-process string-match accept-process-output org-babel-chomp 0] 9 (#$ . 11087)]) #@266 Pass BODY to the Python process in SESSION. 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. (fn SESSION BODY &optional RESULT-TYPE RESULT-PARAMS) (defalias 'org-babel-python-evaluate-session #[1026 "\301\302!\211\303\304\305!!\306\307\310\311\312!\313\"\314$\216r\211q\210c\210)r\211q\210\315\316\211\316\307%\210*\266\317=\203C\320\321\322\"\"\323\"\262\202e\324=\203d\301\302!\325#\323\"\210\326\307\327\"\210\330!\266\202\202e\316\331\235?\205\266\332\235\204\257\333\235\204\257\334\235\204\257\335\235\204\257\336\235\204\257\337\235\204\257\340\235\204\251\341\235\204\251\342\235\204\251\343\235\203\263\344\235\204\263\202\266\345!\262\207" [org-babel-python--exec-tmpfile org-babel-temp-file "python-" get-buffer-create generate-new-buffer-name " *temp file*" make-byte-code 0 "\301\300!\205 \302\300!\207" vconcat vector [buffer-name kill-buffer] 2 write-region nil output format org-babel-process-file-name noquote org-babel-python--send-string value org-babel-python-format-session-value sleep-for 10 org-babel-eval-read-file "none" "scalar" "verbatim" "html" "code" "pp" "file" "output" "raw" "org" "drawer" "table" org-babel-python-table-or-string] 13 (#$ . 11917)]) #@52 Strip \='s from around Python string. (fn STRING) (defalias 'org-babel-python-read-string #[257 "\300\301\"\203\302\301\"\203\211\303\304O\207\207" [string-prefix-p "'" string-suffix-p 1 -1] 4 (#$ . 13276)]) (provide 'ob-python)