From 591a7280ff59569ea18381ee1ee4bd5f5893ffb9 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Mon, 30 Aug 2021 01:02:38 +0530 Subject: [PATCH] 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 --- src/scancode/cli.py | 13 +++++++++++++ src/scancode_config.py | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/scancode/cli.py b/src/scancode/cli.py index c6fdd7e2b1f..2ce49298b24 100644 --- a/src/scancode/cli.py +++ b/src/scancode/cli.py @@ -94,6 +94,7 @@ def print_version(ctx, param, value): if not value or ctx.resilient_parsing: return click.echo('ScanCode version ' + scancode_config.__version__) + click.echo('ScanCode Data-format version ' + scancode_config.__output_format_version__) ctx.exit() @@ -249,6 +250,13 @@ def validate_depth(ctx, param, value): 'the starting directory. Use 0 for no scan depth limit.', help_group=cliutils.CORE_GROUP, sort_order=301, cls=PluggableCommandLineOption) +@click.option('--next-data-format', + is_flag=True, + help='Output the next experimental data format, for JSON and YAML output.' + 'See CHANGELOG for more details on the changes in this experimental data format.', + help_group=cliutils.OUTPUT_GROUP, sort_order=28, cls=PluggableCommandLineOption) + + @click.help_option('-h', '--help', help_group=cliutils.DOC_GROUP, sort_order=10, cls=PluggableCommandLineOption) @@ -337,6 +345,7 @@ def scancode( verbose, max_depth, from_json, + next_data_format, timing, max_in_memory, test_mode, @@ -439,6 +448,7 @@ def scancode( quiet=quiet, verbose=verbose, max_depth=max_depth, + next_data_format=next_data_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -474,6 +484,7 @@ def scancode( def run_scan( input, # NOQA from_json=False, + next_data_format=False, strip_root=False, full_root=False, max_in_memory=10000, @@ -580,6 +591,7 @@ def echo_func(*_args, **_kwargs): quiet=quiet, verbose=verbose, from_json=from_json, + next_data_format=next_data_format, timing=timing, max_in_memory=max_in_memory, test_mode=test_mode, @@ -828,6 +840,7 @@ def echo_func(*_args, **_kwargs): cle.start_timestamp = start_timestamp cle.tool_name = 'scancode-toolkit' cle.tool_version = scancode_config.__version__ + cle.output_format_version = scancode_config.__output_format_version__ cle.notice = notice cle.options = pretty_params or {} diff --git a/src/scancode_config.py b/src/scancode_config.py index e560e1e18f3..1d5ac8eae06 100644 --- a/src/scancode_config.py +++ b/src/scancode_config.py @@ -75,6 +75,11 @@ def _create_dir(location): # in case package is not installed or we do not have setutools/pkg_resources # on hand fall back to this version __version__ = '21.8.4' + +# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information +# on the data format version +__output_format_version__ == '1.1' + try: from pkg_resources import get_distribution, DistributionNotFound try: