Function: python--list-imports
python--list-imports is a byte-compiled function defined in
python.el.gz.
Signature
(python--list-imports NAME SOURCE)
Documentation
List all Python imports matching NAME in SOURCE.
If NAME is nil, list all imports. SOURCE can be a buffer or a list of file names or directories; the latter are searched recursively.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python--list-imports (name source)
"List all Python imports matching NAME in SOURCE.
If NAME is nil, list all imports. SOURCE can be a buffer or a
list of file names or directories; the latter are searched
recursively."
(let ((buffer (current-buffer)))
(with-temp-buffer
(let* ((temp (current-buffer))
(status (if (bufferp source)
(with-current-buffer source
(call-process-region (point-min) (point-max)
python-interpreter
nil (list temp nil) nil
"-c" python--list-imports
(or name "")))
(with-current-buffer buffer
(apply #'call-process
python-interpreter
nil (list temp nil) nil
"-c" python--list-imports
(or name "")
(mapcar #'file-local-name source)))))
lines)
(unless (eq 0 status)
(error "%s exited with status %s (maybe isort is missing?)"
python-interpreter status))
(goto-char (point-min))
(while (not (eobp))
(push (buffer-substring-no-properties (point) (pos-eol))
lines)
(forward-line 1))
(nreverse lines)))))