Megatest

Diff
Login

Differences From Artifact [c034045a40]:

To Artifact [e78af9bffb]:


13
14
15
16
17
18
19

20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+







;; Config file handling
;;======================================================================

(use regex regex-case) ;;  directory-utils)
(declare (unit configf))
(declare (uses process))
(declare (uses env))
(declare (uses keys))

(include "common_records.scm")

;; return list (path fullpath configname)
(define (find-config configname #!key (toppath #f))
  (if toppath
      (let ((cfname (conc toppath "/" configname)))
651
652
653
654
655
656
657

658



659
660


661
662

663
664
665
666














667
668
669
670
671
672
673
652
653
654
655
656
657
658
659
660
661
662
663


664
665
666
667
668




669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689







+

+
+
+
-
-
+
+


+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  (let ((ht (make-hash-table)))
    (for-each
     (lambda (section)
       (hash-table-set! ht (car section)(cdr section)))
     adat)
    ht))

;; if 
(define (configf:read-alist fname)
  (handle-exceptions
      exn
      #f
  (configf:alist->config
   (with-input-from-file fname read)))
    (configf:alist->config
     (with-input-from-file fname read))))

(define (configf:write-alist cdat fname)
  (let ((dat  (configf:config->alist cdat)))
  (with-output-to-file fname
    (lambda ()
      (pp (configf:config->alist cdat)))))
     
    (with-output-to-file fname ;; first write out the file
      (lambda ()
	(pp dat)))
    (if (common:file-exists? fname)   ;; now verify it is readable
	(if (configf:read-alist fname)
	    #t ;; data is good.
	    (begin
	      (handle-exceptions
		  exn
		  #f
		(debug:print 0 *default-log-port* "WARNING: content " dat " for cache " fname " is not readable. Deleting generated file.")
		(delete-file fname))
	      #f))
	#f)))

;; convert hierarchial list to ini format
;;
(define (configf:config->ini data)
  (map 
   (lambda (section)
     (let ((section-name (car section))