Commit e519e8d6 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

kernels: Add 'available-kernel-specs-files'.

* jupyter/kernels.scm (available-kernel-specs-files): New procedure.
parent b7b2ff26
......@@ -23,6 +23,7 @@
#:use-module (gcrypt base64)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 match)
#:use-module (ice-9 ftw)
#:use-module (simple-zmq)
#:use-module (json)
#:use-module (rnrs bytevectors)
......@@ -33,6 +34,7 @@
#:use-module (srfi srfi-71)
#:export (find-kernel-specs
find-kernel-specs-file
available-kernel-specs-files
exec-kernel
spawn-kernel
run-kernel
......@@ -192,6 +194,24 @@ could not be found."
(and (file-exists? json) json)))
path))
(define* (available-kernel-specs-files #:optional
(path (jupyter-kernel-path)))
"Return the list of available kernel specs files (the 'kernel.json' files)
found in PATH."
(define (not-dot? file)
(not (member file '("." ".."))))
(append-map (lambda (directory)
(let* ((directory (string-append directory "/kernels"))
(entries (map (cut string-append directory "/" <>)
(or (scandir directory not-dot?) '()))))
(filter-map (lambda (entry)
(let ((spec (string-append entry
"/kernel.json")))
(and (file-exists? spec) spec)))
entries)))
path))
;;
;; Kernel "connection files".
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment