~aleteoryx/tclircc

ref: 71f49993d7ef1290feb22e882119285f8790d110 tclircc/src/spdx/lib.tcl -rw-r--r-- 1.2 KiB
71f49993aleteoryx docs generation a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#***
# [manpage_begin spdx tclircc 0.0.1]
# [titledesc {Library spdx/lib.tcl}]
# [description]

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
  }
}

#***
# [manpage_end]