Random Bits of Open Code

Check-in [c358d9e639]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added "add-eval-string" to mtconfigf, which allows mtconfig consumer to add things like "(use my-module)" to import apis to #{scheme ..} and the like
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c358d9e639e73c92b02a67a78c37e6cb1ed69472
User & Date: bjbarcla 2018-12-19 01:12:25
Context
2018-12-21
01:03
adjusted evaled calls to mtconfig methods to properly reflect namespace check-in: 48bff81ed5 user: bjbarcla tags: trunk
2018-12-19
01:12
added "add-eval-string" to mtconfigf, which allows mtconfig consumer to add things like "(use my-module)" to import apis to #{scheme ..} and the like check-in: c358d9e639 user: bjbarcla tags: trunk
2018-12-18
20:10
updated method to set repository path to enable build-private egg installs check-in: 74dfe92eac user: bjbarcla tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to mtutils/mtconfigf/mtconfigf.scm.

61
62
63
64
65
66
67
68


69
70
71
72
73
74
75
...
123
124
125
126
127
128
129













130
131
132
133
134
135
136
...
329
330
331
332
333
334
335


336
337
338
339
340
341
342
343
	 map-all-hier-alist
	 config->alist
	 alist->config
	 read-alist
	 write-alist
	 config->ini
	 set-verbosity



         squelch-debug-prints
         )

(import scheme chicken data-structures extras ports files)
(use posix typed-records srfi-18 pathname-expand posix-extras)
(use regex regex-case srfi-69 srfi-1 directory-utils extras srfi-13 )
(import posix)
................................................................................


;; if it looks like a number -> convert it to a number, else return it
;;
(define (lazy-convert inval)
  (let* ((as-num (if (string? inval)(string->number inval) #f)))
    (or as-num inval)))














;; Moved to common
;;
;; return list (path fullpath configname)
(define (find-config configname #!key (toppath #f))
  (if toppath
      (let ((cfname (conc toppath "/" configname)))
................................................................................
		     (allsnip (conc "(define getenv get-environment-variable)"
                                    (if (and (not (get-environment-variable "CHICKEN_REPOSITORY"))
                                             (directory-exists? libpath))
                                        (conc "(repository-path \""libpath"\") ")
                                        "")
                                    "(use mtconfigf)"
				    ;;                ../../eggs/lib/chicken/7/mtconfigf.so


				    "(import mtconfigf)")) ;; (import mtconfigf)")
		     (fullcmd (case cmdsym
				((scheme scm) (conc "(lambda (ht)" allsnip "" cmd ")"))
				((system)     (conc "(lambda (ht)" allsnip "(configf:system ht \"" cmd "\"))"))
				((shell sh)   (conc "(lambda (ht)" allsnip "(string-translate (shell \""  cmd "\") \"\n\" \" \"))"))
				((realpath rp)(conc "(lambda (ht)" allsnip "(nice-path \"" cmd "\"))"))
				((getenv gv)  (conc "(lambda (ht)" allsnip "(get-environment-variable \"" cmd "\"))"))
				((mtrah)      (conc "(lambda (ht)" allsnip







|
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
	 map-all-hier-alist
	 config->alist
	 alist->config
	 read-alist
	 write-alist
	 config->ini
	 set-verbosity
         add-eval-string
         ;;import-module
         ;; import-proc
         squelch-debug-prints
         )

(import scheme chicken data-structures extras ports files)
(use posix typed-records srfi-18 pathname-expand posix-extras)
(use regex regex-case srfi-69 srfi-1 directory-utils extras srfi-13 )
(import posix)
................................................................................


;; if it looks like a number -> convert it to a number, else return it
;;
(define (lazy-convert inval)
  (let* ((as-num (if (string? inval)(string->number inval) #f)))
    (or as-num inval)))


(define *eval-string* "")
(define (add-eval-string str)
  (set! *eval-string* (conc *eval-string* " " str)))

;;(define (import-proc name-sym the-proc) ;; does not work
;;  (let* ((wrapper (lambda x (apply the-proc x))))
;;    (eval `(define ,name-sym wrapper))))

;;(define (import-module mname) ;; does not work
;;  (eval (with-input-from-string (conc "(import "mname")") read)))


;; Moved to common
;;
;; return list (path fullpath configname)
(define (find-config configname #!key (toppath #f))
  (if toppath
      (let ((cfname (conc toppath "/" configname)))
................................................................................
		     (allsnip (conc "(define getenv get-environment-variable)"
                                    (if (and (not (get-environment-variable "CHICKEN_REPOSITORY"))
                                             (directory-exists? libpath))
                                        (conc "(repository-path \""libpath"\") ")
                                        "")
                                    "(use mtconfigf)"
				    ;;                ../../eggs/lib/chicken/7/mtconfigf.so
				    "(import mtconfigf)"
                                    *eval-string*
                                    )) ;; (import mtconfigf)")
		     (fullcmd (case cmdsym
				((scheme scm) (conc "(lambda (ht)" allsnip "" cmd ")"))
				((system)     (conc "(lambda (ht)" allsnip "(configf:system ht \"" cmd "\"))"))
				((shell sh)   (conc "(lambda (ht)" allsnip "(string-translate (shell \""  cmd "\") \"\n\" \" \"))"))
				((realpath rp)(conc "(lambda (ht)" allsnip "(nice-path \"" cmd "\"))"))
				((getenv gv)  (conc "(lambda (ht)" allsnip "(get-environment-variable \"" cmd "\"))"))
				((mtrah)      (conc "(lambda (ht)" allsnip