import: utils: Refactor license->symbol.
* guix/import/utils.scm (license->symbol): Work for all licenses. * tests/import-utils.scm (license->symbol): Add test.
This commit is contained in:
parent
59b2034787
commit
11e296ef30
|
@ -1,6 +1,7 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
|
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
|
||||||
|
;;; Copyright © 2016 David Craven <david@craven.ch>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -185,15 +186,10 @@ recursively apply the procedure to the sub-list."
|
||||||
(define (license->symbol license)
|
(define (license->symbol license)
|
||||||
"Convert license to a symbol representing the variable the object is bound
|
"Convert license to a symbol representing the variable the object is bound
|
||||||
to in the (guix licenses) module, or #f if there is no such known license."
|
to in the (guix licenses) module, or #f if there is no such known license."
|
||||||
;; TODO: Traverse list public variables in (guix licenses) instead so we
|
(define licenses
|
||||||
;; don't have to maintain a list manualy.
|
(module-map (lambda (sym var) `(,(variable-ref var) . ,sym))
|
||||||
(assoc-ref `((,license:lgpl2.0 . license:lgpl2.0)
|
(resolve-interface '(guix licenses) #:prefix 'license:)))
|
||||||
(,license:gpl3 . license:gpl3)
|
(assoc-ref licenses license))
|
||||||
(,license:bsd-3 . license:bsd-3)
|
|
||||||
(,license:expat . license:expat)
|
|
||||||
(,license:public-domain . license:public-domain)
|
|
||||||
(,license:asl2.0 . license:asl2.0))
|
|
||||||
license))
|
|
||||||
|
|
||||||
(define (snake-case str)
|
(define (snake-case str)
|
||||||
"Return a downcased version of the string STR where underscores are replaced
|
"Return a downcased version of the string STR where underscores are replaced
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
(define-module (test-import-utils)
|
(define-module (test-import-utils)
|
||||||
#:use-module (guix tests)
|
#:use-module (guix tests)
|
||||||
#:use-module (guix import utils)
|
#:use-module (guix import utils)
|
||||||
|
#:use-module ((guix licenses) #:prefix license:)
|
||||||
#:use-module (srfi srfi-64))
|
#:use-module (srfi srfi-64))
|
||||||
|
|
||||||
(test-begin "import-utils")
|
(test-begin "import-utils")
|
||||||
|
@ -33,4 +34,8 @@
|
||||||
"This package provides a function to establish world peace"
|
"This package provides a function to establish world peace"
|
||||||
(beautify-description "A function to establish world peace"))
|
(beautify-description "A function to establish world peace"))
|
||||||
|
|
||||||
|
(test-equal "license->symbol"
|
||||||
|
'license:lgpl2.0
|
||||||
|
(license->symbol license:lgpl2.0))
|
||||||
|
|
||||||
(test-end "import-utils")
|
(test-end "import-utils")
|
||||||
|
|
Loading…
Reference in New Issue