Commit 2243f51
committed
Add support for external licenses in scans #480
This adds `-dir` or `--additional-directories` as a command line
option in license detection. This allows users to specify paths to
directories of licenses and rules they'd like to use during license
detection, but would not like to add to the ScanCode database of
licenses.
This involves adding a new option in `licensedcode/plugin_license.py`,
and this option is used as a parameter in `scancode/api.py`. In this
approach, the licenses and rules contained in these additional
directories are combined with the existing licenses and rules in the
ScanCode database to produce a single index. The code for this is found
in `licensedcode/cache.py` and the helper methods for loading these
licenses and rules are found in `licensedcode/models.py`. This commit
also includes a unit test to verify that license detection succeeds
with an additional directory found in
`tests/licensedcode/test_plugin_license.py`. Part of the setup for the
unit test and future tests involves creating a new directory in
`tests/licensedcode/data` that contains sample external licenses used
in the unit tests.
Signed-off-by: Kevin Ji <kyji1011@gmail.com>1 parent 7394e79 commit 2243f51
17 files changed
Lines changed: 445 additions & 30 deletions
File tree
- src
- licensedcode
- scancode
- tests
- licensedcode
- data
- example_external_licenses
- example1
- licenses
- rules
- example2
- licenses
- rules
- plugin_license/external_licenses
- scan
- scancode/data/help
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| |||
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
80 | 102 | | |
81 | 103 | | |
82 | | - | |
| 104 | + | |
83 | 105 | | |
84 | 106 | | |
85 | 107 | | |
| |||
92 | 114 | | |
93 | 115 | | |
94 | 116 | | |
| 117 | + | |
| 118 | + | |
95 | 119 | | |
96 | 120 | | |
97 | 121 | | |
| |||
106 | 130 | | |
107 | 131 | | |
108 | 132 | | |
109 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
110 | 139 | | |
| 140 | + | |
| 141 | + | |
111 | 142 | | |
112 | 143 | | |
113 | 144 | | |
114 | 145 | | |
115 | 146 | | |
| 147 | + | |
116 | 148 | | |
117 | 149 | | |
118 | 150 | | |
| |||
131 | 163 | | |
132 | 164 | | |
133 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
134 | 170 | | |
135 | 171 | | |
136 | 172 | | |
| |||
143 | 179 | | |
144 | 180 | | |
145 | 181 | | |
| 182 | + | |
146 | 183 | | |
147 | 184 | | |
148 | 185 | | |
149 | 186 | | |
150 | 187 | | |
151 | 188 | | |
| 189 | + | |
| 190 | + | |
152 | 191 | | |
153 | 192 | | |
| 193 | + | |
| 194 | + | |
154 | 195 | | |
| 196 | + | |
155 | 197 | | |
156 | 198 | | |
157 | 199 | | |
158 | 200 | | |
159 | 201 | | |
| 202 | + | |
160 | 203 | | |
161 | 204 | | |
162 | 205 | | |
163 | 206 | | |
164 | 207 | | |
165 | | - | |
166 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
167 | 226 | | |
168 | 227 | | |
169 | 228 | | |
| |||
299 | 358 | | |
300 | 359 | | |
301 | 360 | | |
302 | | - | |
| 361 | + | |
303 | 362 | | |
304 | 363 | | |
305 | 364 | | |
306 | 365 | | |
307 | 366 | | |
308 | 367 | | |
309 | 368 | | |
310 | | - | |
| 369 | + | |
311 | 370 | | |
312 | 371 | | |
313 | 372 | | |
314 | 373 | | |
315 | | - | |
| 374 | + | |
316 | 375 | | |
317 | 376 | | |
318 | 377 | | |
| |||
325 | 384 | | |
326 | 385 | | |
327 | 386 | | |
| 387 | + | |
328 | 388 | | |
329 | 389 | | |
330 | 390 | | |
| |||
346 | 406 | | |
347 | 407 | | |
348 | 408 | | |
349 | | - | |
| 409 | + | |
350 | 410 | | |
351 | 411 | | |
352 | 412 | | |
353 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
354 | 418 | | |
355 | 419 | | |
356 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
772 | 773 | | |
773 | 774 | | |
774 | 775 | | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
775 | 838 | | |
776 | 839 | | |
777 | 840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
| |||
167 | 177 | | |
168 | 178 | | |
169 | 179 | | |
170 | | - | |
| 180 | + | |
| 181 | + | |
171 | 182 | | |
172 | 183 | | |
173 | 184 | | |
| |||
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
| |||
186 | 198 | | |
187 | 199 | | |
188 | 200 | | |
| 201 | + | |
189 | 202 | | |
190 | 203 | | |
191 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| 256 | + | |
255 | 257 | | |
256 | 258 | | |
257 | 259 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments