use yml data structures with python parser
This commit is contained in:
parent
8dfbc5ef25
commit
f0ffd3f630
@ -1,8 +1,10 @@
|
||||
#(define noStandaloneOutput (if (defined? 'noStandaloneOutput) noStandaloneOutput #f))
|
||||
|
||||
#(if (defined? 'LAYOUT) #f (load (string-append (dirname (current-filename)) file-name-separator-string "json_parser.scm")))
|
||||
#(use-modules (json parser))
|
||||
\include "resolve_inherits.ly"
|
||||
#(if (defined? 'LAYOUT) #f
|
||||
(let ((scmdir (string-append (dirname (current-filename)) file-name-separator-string "scm" file-name-separator-string)))
|
||||
(load (string-append scmdir "json_parser.scm"))
|
||||
(load (string-append scmdir "resolve_inherits.scm"))
|
||||
(load (string-append scmdir "yaml_parser.scm"))))
|
||||
\include "basic_format_and_style_settings.ly"
|
||||
\include "eps_file_from_song_dir.ly"
|
||||
\include "title_with_category_images.ly"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#(define (resolve-inherit-entry-in-list alist entry)
|
||||
(define (resolve-inherit-entry-in-list alist entry)
|
||||
(let* ((key (car entry))
|
||||
(attributes (cdr entry))
|
||||
(inherits (assoc-ref attributes "inherits")))
|
||||
@ -17,6 +17,6 @@
|
||||
entry
|
||||
)))
|
||||
|
||||
#(define (resolve-inherits alist)
|
||||
(define (resolve-inherits alist)
|
||||
(map (lambda (entry) (resolve-inherit-entry-in-list alist entry)) alist)
|
||||
)
|
10
scm/yaml_parser.scm
Normal file
10
scm/yaml_parser.scm
Normal file
@ -0,0 +1,10 @@
|
||||
(use-modules (ice-9 popen) (ice-9 textual-ports) (json parser))
|
||||
|
||||
(define (yml-file->scm filename)
|
||||
(let* ((python_cmd (string-append "import sys, yaml, json; print(json.dumps(yaml.safe_load(open('" filename "'))))"))
|
||||
(pipe (open-pipe* OPEN_READ "python" "-c" python_cmd))
|
||||
(json (get-string-all pipe)))
|
||||
(close-pipe pipe)
|
||||
(json-string->scm json)))
|
||||
|
||||
(define (parse-yml-file filename) (resolve-inherits (yml-file->scm filename)))
|
Loading…
Reference in New Issue
Block a user