Use progress-advance.

This commit is contained in:
Dominik Pantůček 2023-03-20 16:16:40 +01:00
parent ce348ae901
commit 08ad923f6a
3 changed files with 43 additions and 38 deletions

View file

@ -58,8 +58,9 @@
ansi
period
month
configuration)
configuration
progress)
;; Gets all files and symbolic links from given directory. The
;; symbolic links are represented by cons cells with car being the
;; name and cdr the link target.
@ -172,30 +173,28 @@
(define (load-members dn . opts)
(let ((progress? (and (not (null? opts))
(car opts))))
(when progress?
(display "Loading members "))
(let* ((fss (files-dictionary-filter-4digit-symbols
(files+symlinks->files-dictionary
(get-files+symlinks dn))))
(mb0 (dict-map
(lambda (symfn symlinks)
(when progress?
(display "."))
(members-base-load-member dn
symfn
symlinks))
fss))
(mb1 (dict-reduce (make-dict)
(lambda (acc symfn mr)
(dict-set acc (dict-ref mr 'id) mr))
mb0))
(mb (dict-reduce '()
(lambda (acc id mr)
(cons mr acc))
mb1)))
(when progress?
(print " ok."))
mb)))
(with-progress
progress? "Loading-members " " ok."
(let* ((fss (files-dictionary-filter-4digit-symbols
(files+symlinks->files-dictionary
(get-files+symlinks dn))))
(mb0 (dict-map
(lambda (symfn symlinks)
(when progress?
(progress-advance "."))
(members-base-load-member dn
symfn
symlinks))
fss))
(mb1 (dict-reduce (make-dict)
(lambda (acc symfn mr)
(dict-set acc (dict-ref mr 'id) mr))
mb0))
(mb (dict-reduce '()
(lambda (acc id mr)
(cons mr acc))
mb1)))
mb))))
;; Gets member based by generic predicate
(define (find-member-by-predicate mb pred)