Skip to content

Commit

Permalink
Introduce output data format versioning #2653
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
AyanSinhaMahapatra committed Aug 29, 2021
1 parent 3be07db commit 591a728
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/scancode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -337,6 +345,7 @@ def scancode(
verbose,
max_depth,
from_json,
next_data_format,
timing,
max_in_memory,
test_mode,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {}

Expand Down
5 changes: 5 additions & 0 deletions src/scancode_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 591a728

Please sign in to comment.