namespace eval spdx {
set log [logger::init spdx]
variable db
proc load {} {
variable log
variable db
if {[array exists db]} { return }
${log}::debug "loading database..."
set dump_path [dict get [info frame [info frame]] file]
set dump_path [file dirname $dump_path]
set dump_path [file join $dump_path dump.tcldict.gz]
set dump [open $dump_path]
zlib push gunzip $dump
set data [read $dump]
close $dump
unset dump
unset dump_path
foreach {name info} $data {
set db($name) $info
}
unset data
${log}::debug "database loaded with [array size db] licenses!"
}
proc exists {id} {
variable db
::spdx::load
expr {$id in [array names db -exact $id]}
}
proc get_name {id} {
variable db
::spdx::load
dict get [set db($id)] name
}
proc get_text {id} {
variable db
::spdx::load
dict get [set db($id)] text
}
proc get_spdx_url {id} {
variable db
::spdx::load
dict get [set db($id)] spdx_url
}
proc get_see_also {id} {
variable db
::spdx::load
dict get [set db($id)] see_also
}
}