Skip to content

Commit fa3e366

Browse files
authored
Merge pull request #2472 from nexB/make-reindex-licenses-work
Prep release 21.3.31
2 parents 9ccecc5 + a02740d commit fa3e366

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ License scanning:
3939

4040

4141

42-
v21.3.30
42+
v21.3.31
4343
--------
4444

4545
This is a major version with no breaking API changes. Heads-up: the next version

setup-mini.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = scancode-toolkit-mini
3-
version = 21.3.30
3+
version = 21.3.31
44
license = Apache-2.0 AND CC-BY-4.0 AND LicenseRef-scancode-other-permissive AND LicenseRef-scancode-other-copyleft
55

66
description = ScanCode is a tool to scan code for license, copyright, package and their documented dependencies and other interesting facts. scancode-toolkit-mini is a special build that does not come with pre-built binary dependencies by default. These are instead installed separately or with the extra_requires scancode-toolkit-mini[full]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = scancode-toolkit
3-
version = 21.3.30
3+
version = 21.3.31
44
license = Apache-2.0 AND CC-BY-4.0 AND LicenseRef-scancode-other-permissive AND LicenseRef-scancode-other-copyleft
55

66
description = ScanCode is a tool to scan code for license, copyright, package and their documented dependencies and other interesting facts.

src/licensedcode/cache.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ def build_unknown_spdx_symbol(licenses_db=None):
266266
return LicenseSymbolLike(licenses[u'unknown-spdx'])
267267

268268

269-
def get_cache():
269+
def get_cache(check_consistency=SCANCODE_DEV_MODE):
270270
"""
271271
Optionally return and either load or build and cache a LicenseCache.
272272
"""
273-
populate_cache()
273+
populate_cache(check_consistency=check_consistency)
274274
global _LICENSE_CACHE
275275
return _LICENSE_CACHE
276276

277277

278-
def populate_cache():
278+
def populate_cache(check_consistency=SCANCODE_DEV_MODE):
279279
"""
280280
Load or build and cache a LicenseCache. Return None.
281281
"""
@@ -284,7 +284,7 @@ def populate_cache():
284284
_LICENSE_CACHE = LicenseCache.load_or_build(
285285
licensedcode_cache_dir=licensedcode_cache_dir,
286286
scancode_cache_dir=scancode_cache_dir,
287-
check_consistency=SCANCODE_DEV_MODE,
287+
check_consistency=check_consistency,
288288
# used for testing only
289289
timeout=LICENSE_INDEX_LOCK_TIMEOUT,
290290
tree_base_dir=scancode_src_dir,
@@ -338,39 +338,42 @@ def tree_checksum(tree_base_dir=licensedcode_dir, _ignored=_ignored_from_hash):
338338
return md5(hashable).hexdigest()
339339

340340

341-
def get_index():
341+
def get_index(check_consistency=SCANCODE_DEV_MODE):
342342
"""
343343
Return and eventually build and cache a LicenseIndex.
344344
"""
345-
return get_cache().index
345+
return get_cache(check_consistency=check_consistency).index
346346

347347

348-
def get_licenses_db():
348+
get_cached_index = get_index
349+
350+
351+
def get_licenses_db(check_consistency=SCANCODE_DEV_MODE):
349352
"""
350353
Return a mapping of license key -> license object.
351354
"""
352-
return get_cache().db
355+
return get_cache(check_consistency=check_consistency).db
353356

354357

355-
def get_licensing():
358+
def get_licensing(check_consistency=SCANCODE_DEV_MODE):
356359
"""
357360
Return a license_expression.Licensing objet built from the all the licenses.
358361
"""
359-
return get_cache().licensing
362+
return get_cache(check_consistency=check_consistency).licensing
360363

361364

362-
def get_unknown_spdx_symbol():
365+
def get_unknown_spdx_symbol(check_consistency=SCANCODE_DEV_MODE):
363366
"""
364367
Return the unknown SPDX license symbol.
365368
"""
366-
return get_cache().unknown_spdx_symbol
369+
return get_cache(check_consistency=check_consistency).unknown_spdx_symbol
367370

368371

369-
def get_spdx_symbols(licenses_db=None):
372+
def get_spdx_symbols(licenses_db=None, check_consistency=SCANCODE_DEV_MODE):
370373
"""
371374
Return a mapping of {lowercased SPDX license key: LicenseSymbolLike} where
372375
LicenseSymbolLike wraps a License object
373376
"""
374377
if licenses_db:
375378
return build_spdx_symbols(licenses_db)
376-
return get_cache().spdx_symbols
379+
return get_cache(check_consistency=check_consistency).spdx_symbols

src/licensedcode/plugin_license.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def reindex_licenses(ctx, param, value):
2525
return
2626

2727
# TODO: check for temp file configuration and use that for the cache!!!
28-
from licensedcode.cache import get_cached_index
28+
from licensedcode.cache import get_index
2929
import click
3030
click.echo('Checking and rebuilding the license index...')
31-
get_cached_index(check_consistency=True,)
31+
get_index(check_consistency=True)
3232
click.echo('Done.')
3333
ctx.exit(0)
3434

src/scancode_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _create_dir(location):
7979
except (DistributionNotFound, ImportError):
8080
# package is not installed or we do not have setutools/pkg_resources
8181
# on hand
82-
__version__ = '21.3.1'
82+
__version__ = '21.3.31'
8383

8484
system_temp_dir = tempfile.gettempdir()
8585
scancode_src_dir = dirname(__file__)

tests/licensedcode/test_plugin_license.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ def test_license_option_reports_license_texts_diag_long_lines():
6868
check_json_scan(test_loc, result_file, regen=False)
6969

7070

71+
def test_reindex_licenses_works():
72+
args = ['--reindex-licenses']
73+
run_scan_click(args)
74+
75+
7176
@pytest.mark.scanslow
7277
def test_scan_license_with_url_template():
7378
test_dir = test_env.get_test_loc('plugin_license/license_url', copy=True)

0 commit comments

Comments
 (0)