Skip to content

Commit 591a728

Browse files
Introduce output data format versioning #2653
Add output data format version numbers to the headers and version help text. Introduce new command line option to switch to the new experimental data format. Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent 3be07db commit 591a728

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/scancode/cli.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def print_version(ctx, param, value):
9494
if not value or ctx.resilient_parsing:
9595
return
9696
click.echo('ScanCode version ' + scancode_config.__version__)
97+
click.echo('ScanCode Data-format version ' + scancode_config.__output_format_version__)
9798
ctx.exit()
9899

99100

@@ -249,6 +250,13 @@ def validate_depth(ctx, param, value):
249250
'the starting directory. Use 0 for no scan depth limit.',
250251
help_group=cliutils.CORE_GROUP, sort_order=301, cls=PluggableCommandLineOption)
251252

253+
@click.option('--next-data-format',
254+
is_flag=True,
255+
help='Output the next experimental data format, for JSON and YAML output.'
256+
'See CHANGELOG for more details on the changes in this experimental data format.',
257+
help_group=cliutils.OUTPUT_GROUP, sort_order=28, cls=PluggableCommandLineOption)
258+
259+
252260
@click.help_option('-h', '--help',
253261
help_group=cliutils.DOC_GROUP, sort_order=10, cls=PluggableCommandLineOption)
254262

@@ -337,6 +345,7 @@ def scancode(
337345
verbose,
338346
max_depth,
339347
from_json,
348+
next_data_format,
340349
timing,
341350
max_in_memory,
342351
test_mode,
@@ -439,6 +448,7 @@ def scancode(
439448
quiet=quiet,
440449
verbose=verbose,
441450
max_depth=max_depth,
451+
next_data_format=next_data_format,
442452
timing=timing,
443453
max_in_memory=max_in_memory,
444454
test_mode=test_mode,
@@ -474,6 +484,7 @@ def scancode(
474484
def run_scan(
475485
input, # NOQA
476486
from_json=False,
487+
next_data_format=False,
477488
strip_root=False,
478489
full_root=False,
479490
max_in_memory=10000,
@@ -580,6 +591,7 @@ def echo_func(*_args, **_kwargs):
580591
quiet=quiet,
581592
verbose=verbose,
582593
from_json=from_json,
594+
next_data_format=next_data_format,
583595
timing=timing,
584596
max_in_memory=max_in_memory,
585597
test_mode=test_mode,
@@ -828,6 +840,7 @@ def echo_func(*_args, **_kwargs):
828840
cle.start_timestamp = start_timestamp
829841
cle.tool_name = 'scancode-toolkit'
830842
cle.tool_version = scancode_config.__version__
843+
cle.output_format_version = scancode_config.__output_format_version__
831844
cle.notice = notice
832845
cle.options = pretty_params or {}
833846

src/scancode_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def _create_dir(location):
7575
# in case package is not installed or we do not have setutools/pkg_resources
7676
# on hand fall back to this version
7777
__version__ = '21.8.4'
78+
79+
# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information
80+
# on the data format version
81+
__output_format_version__ == '1.1'
82+
7883
try:
7984
from pkg_resources import get_distribution, DistributionNotFound
8085
try:

0 commit comments

Comments
 (0)