\f
;;; Import management
(defconst python--list-imports "\
-from isort import find_imports_in_stream, find_imports_in_paths
-from sys import argv, stdin
+from sys import argv, exit, stdin
+
+try:
+ from isort import find_imports_in_stream, find_imports_in_paths
+except ModuleNotFoundError:
+ exit(1)
+except ImportError:
+ exit(2)
query, files, result = argv[1] or None, argv[2:], {}
(or name "")
(mapcar #'file-local-name source)))))
lines)
- (unless (eq 0 status)
+ (cond
+ ((eq 1 status)
(error "%s exited with status %s (maybe isort is missing?)"
python-interpreter status))
+ ((eq 2 status)
+ (error "%s exited with status %s (maybe isort version is <5.7.0?)"
+ python-interpreter status)))
(goto-char (point-min))
(while (not (eobp))
(push (buffer-substring-no-properties (point) (pos-eol))
nil (list temp nil) nil
"-m" "isort" "-" args))
(tick (buffer-chars-modified-tick)))
- (unless (eq 0 status)
+ (cond
+ ((eq 1 status)
(error "%s exited with status %s (maybe isort is missing?)"
python-interpreter status))
+ ((eq 2 status)
+ (error "%s exited with status %s (maybe isort version is <5.7.0?)"
+ python-interpreter status)))
(replace-buffer-contents temp)
(not (eq tick (buffer-chars-modified-tick)))))))))