diff options
-rwxr-xr-x | generate-ttl-files.scm | 68 |
1 files changed, 21 insertions, 47 deletions
diff --git a/generate-ttl-files.scm b/generate-ttl-files.scm index ded6423..7afbe7b 100755 --- a/generate-ttl-files.scm +++ b/generate-ttl-files.scm @@ -95,14 +95,6 @@ errors." ;; Don't follow symlinks. lstat))) -(define (call-with-temporary-directory proc) - (let ((tmp-dir (mkdtemp "/tmp/generate-ttl-files.XXXXXX"))) - (dynamic-wind - (const #t) - (cut proc tmp-dir) - (cut delete-file-recursively tmp-dir)))) - - (let* ((option-spec '((settings (single-char #\s) (value #t)) (documentation (single-char #\d) (value #t)) @@ -112,42 +104,24 @@ errors." (output (option-ref options 'output #f)) (documentation (option-ref options 'documentation #f)) (%source-dir (dirname (current-filename)))) - (call-with-temporary-directory - (lambda (tmpdir) - (let* ((gn-docs-dir (string-append tmpdir "/gn-docs")) - (rdf-documentation (string-append gn-docs-dir "/rdf-documentation"))) - (unless (file-exists? output) - (mkdir output)) - (system* "git" "clone" "--depth" "1" - documentation gn-docs-dir) - ;; Delete all the files in the gn-docs/rdf-documentation - (for-each (lambda (file) - (delete-file file)) - (find-files rdf-documentation ".md")) - ;; Transform data to RDF - (for-each (lambda (file) - (let* ((base-file-name (basename file ".scm")) - (ttl-file (string-append output "/" base-file-name ".ttl")) - (md-file (format #f "~a/~a.md" rdf-documentation base-file-name))) - ;; Ignore dataset-metadata-git.scm because TODO - (unless (string=? base-file-name "dataset-metadata-git") - (system* "./pre-inst-env" file "--settings" settings - "--output" ttl-file - "--documentation" md-file)))) - (find-files "./examples" ".scm")) - (for-each (lambda (file) - (copy-file - file (format #f "/~a/~a.ttl" output (basename file)))) - (find-files "./schema" ".ttl")) - ;; Validate transformed turtle files - (for-each (lambda (file) - (system* "rapper" "--input" "turtle" "--count" file)) - (append (find-files output ".ttl") - (find-files "./schema" ".ttl"))) - ;; Push changes to git when data is correctly valldated - (unless (zero? (status:exit-val - (system* "git" "-C" gn-docs-dir "diff" "--exit-code"))) - (system* "git" "-C" gn-docs-dir "add" rdf-documentation) - (system* "git" "-C" gn-docs-dir "commit" "--no-gpg-sign" "-m" - "Update RDF documentation.\n\n* Commit made via the generate-ttl-files.scm script\"") - (system* "git" "-C" gn-docs-dir "push" "origin" "master")))))) + (unless (file-exists? output) + (mkdir output)) + ;; Transform data to RDF + (for-each (lambda (file) + (let* ((base-file-name (basename file ".scm")) + (ttl-file (string-append output "/" base-file-name ".ttl"))) + ;; Ignore dataset-metadata-git.scm because TODO + (unless (string=? base-file-name "dataset-metadata-git") + (system* "./pre-inst-env" file "--settings" settings + "--output" ttl-file)))) + (find-files "./examples" ".scm")) + ;; Copy hand-woven ttl files. + (for-each (lambda (file) + (copy-file + file (format #f "~a/~a" output (basename file)))) + (find-files "./schema" ".ttl")) + ;; Validate transformed turtle files + (for-each (lambda (file) + (system* "rapper" "--input" "turtle" "--count" file)) + (append (find-files output ".ttl") + (find-files "./schema" ".ttl")))) |