|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;; This file:
;; http://anggtwu.net/elisp/2025-pyinspect.el.html
;; http://anggtwu.net/elisp/2025-pyinspect.el
;; (find-angg "elisp/2025-pyinspect.el")
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;;
;; (defun e () (interactive) (find-angg "elisp/2025-pyinspect.el"))
;; Based on:
;; (find-telegachat "617713850#244286")
;; (find-wget-elisp "https://0x0.st/8Smg.txt")
; (define-key eev-mode-map "\M-Y" 'eewrap-pyinspect)
(defun eewrap-pyinspect () (interactive)
(ee-this-line-wrapn 1 'ee-wrap-pyinspect))
(defun ee-wrap-pyinspect (var)
"An internal function used by `eewrap-pyinspect'."
(let ((ee-hyperlink-prefix "# "))
(ee-template0 "\
{(ee-HS `(find-pyinspect-links ,var))}")))
(defun find-pyinspect-links (&optional var &rest pos-spec-list)
"Visit a temporary buffer containing hyperlinks for pyinspect."
(interactive)
(setq var (or var "{var}"))
(let* ((ee-hyperlink-prefix "# "))
(apply
'find-elinks
`((find-pyinspect-links ,var ,@pos-spec-list)
;; Convention: the first sexp always regenerates the buffer.
(find-efunction 'find-pyinspect-links)
""
,(ee-template0 "\
from inspect import getmembers, getdoc
from pprint import pprint, pformat
from pathlib import Path
pprint([i for i,_ in getmembers({var})])
print(getdoc({var}))
{var}
dir = Path(\".cachedlinks/\")
if not dir.exists():
dir.mkdir()
with open(\".cachedlinks/{var}.getmembers\", \"w\") as file:
file.write(pformat([i for i,_ in getmembers({var})]))
with open(\".cachedlinks/{var}.getdoc\", \"w\") as file:
file.write(getdoc({var}))
with open(\".cachedlinks/{var}\", \"w\") as file:
file.write(str({var}))
# (find-fline \"./.cachedlinks/{var}.getdoc\")
# (find-fline \"./.cachedlinks/{var}.getmembers\")
# (find-fline \"./.cachedlinks/{var}\")
")
)
pos-spec-list))
(python-mode))
;; """
;; * (eepitch-vterm)
;; mkdir -p ~/teste_pyinspect/
;; cd ~/teste_pyinspect/
;; python -m venv .venv
;; source .venv/bin/activate
;; pip install pandas
;; python
;; * (forward-line)
;; """
;;
;; import pandas
;; df = pandas.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
;; df.loc
;;
;; # (find-pyinspect-links "df.loc")
;; # (find-fline "~/teste_pyinspect/.cachedlinks/df.loc.getdoc")
;; # (find-fline "~/teste_pyinspect/.cachedlinks/df.loc.getmembers")
;; # (find-fline "~/teste_pyinspect/.cachedlinks/df.loc")