Skip to content

Commit

Permalink
Simplify output option names aboutcode-org#789
Browse files Browse the repository at this point in the history
Some output formats were prefixed with "output" while others were not.
For the sake of consistency and simplicity, "output" is dropped as a prefix
to these output options.

Signed-off-by: Yash Nisar <[email protected]>
  • Loading branch information
yash-nisar committed Apr 11, 2018
1 parent eea44b4 commit a4aba95
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 73 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ help. ScanCode will self-configure if needed::

Run a sample scan saved to the `samples.html` file::

./scancode --output-html-app samples.html samples
./scancode --html-app samples.html samples

Then open `samples.html` in your web browser to view the scan results.

Expand Down Expand Up @@ -167,6 +167,6 @@ Run this command for a list of command line examples::

To run a license scan on sample data, first run this::

./scancode -l --output-html-app samples.html samples
./scancode --html-app samples.html samples

Then open samples.html in your web browser to see the results.
6 changes: 3 additions & 3 deletions etc/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ function test_scan {
$cmd
echo "TEST PASSED"

cmd="./scancode --quiet -lcip apache-2.0.LICENSE --output-html test_scan.html"
cmd="./scancode --quiet -lcip apache-2.0.LICENSE --html test_scan.html"
echo "RUNNING TEST: $cmd"
$cmd
echo "TEST PASSED"

cmd="./scancode --quiet -lcip apache-2.0.LICENSE --output-html-app test_scan_app.html"
cmd="./scancode --quiet -lcip apache-2.0.LICENSE --html-app test_scan_app.html"
echo "RUNNING TEST: $cmd"
$cmd
echo "TEST PASSED"

cmd="./scancode --quiet -lcip apache-2.0.LICENSE --output-spdx-tv test_scan.spdx"
cmd="./scancode --quiet -lcip apache-2.0.LICENSE --spdx-tv test_scan.spdx"
echo "RUNNING TEST: $cmd"
$cmd
echo "TEST PASSED"
Expand Down
10 changes: 5 additions & 5 deletions src/formattedcode/output_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
class CsvOutput(OutputPlugin):

options = [
CommandLineOption(('--output-csv',),
CommandLineOption(('--csv',),
type=FileOptionType(mode='wb', lazy=False),
metavar='FILE',
help='Write scan output as CSV to FILE.',
help_group=OUTPUT_GROUP,
sort_order=30),
]

def is_enabled(self, output_csv, **kwargs):
return output_csv
def is_enabled(self, csv, **kwargs):
return csv

def process_codebase(self, codebase, output_csv, **kwargs):
def process_codebase(self, codebase, csv, **kwargs):
results = self.get_results(codebase, **kwargs)
write_csv(results, output_csv)
write_csv(results, csv)


def write_csv(results, output_file):
Expand Down
34 changes: 17 additions & 17 deletions src/formattedcode/output_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,28 +68,28 @@
class HtmlOutput(OutputPlugin):

options = [
CommandLineOption(('--output-html',),
CommandLineOption(('--html',),
type=FileOptionType(mode='wb', lazy=False),
metavar='FILE',
help='Write scan output as HTML to FILE.',
help_group=OUTPUT_GROUP,
sort_order=50),
]

def is_enabled(self, output_html, **kwargs):
return output_html
def is_enabled(self, html, **kwargs):
return html

def process_codebase(self, codebase, output_html, scancode_version, **kwargs):
def process_codebase(self, codebase, html, scancode_version, **kwargs):
results = self.get_results(codebase, **kwargs)
write_templated(output_html, results, scancode_version,
write_templated(html, results, scancode_version,
template_or_format='html')


@output_impl
class CustomTemplateOutput(OutputPlugin):

options = [
CommandLineOption(('--output-custom',),
CommandLineOption(('--custom-output',),
type=FileOptionType(mode='wb', lazy=False),
requires=['custom_template'],
metavar='FILE',
Expand All @@ -102,23 +102,23 @@ class CustomTemplateOutput(OutputPlugin):
type=click.Path(
exists=True, file_okay=True, dir_okay=False,
readable=True, path_type=PATH_TYPE),
requires=['output_custom'],
requires=['custom_output'],
metavar='FILE',
help='Use this Jinja template FILE as a custom template.',
help_group=OUTPUT_GROUP,
sort_order=65),
]

def is_enabled(self, output_custom, custom_template, **kwargs):
return output_custom and custom_template
def is_enabled(self, custom_output, custom_template, **kwargs):
return custom_output and custom_template

def process_codebase(self, codebase, output_custom, custom_template,
def process_codebase(self, codebase, custom_output, custom_template,
scancode_version, **kwargs):

results = self.get_results(codebase, **kwargs)
if on_linux:
custom_template = fsencode(custom_template)
write_templated(output_custom, results, scancode_version,
write_templated(custom_output, results, scancode_version,
template_or_format=custom_template)


Expand All @@ -128,25 +128,25 @@ class HtmlAppOutput(OutputPlugin):
Write scan output as a mini HTML application.
"""
options = [
CommandLineOption(('--output-html-app',),
CommandLineOption(('--html-app',),
type=FileOptionType(mode='wb', lazy=False),
metavar='FILE',
help='Write scan output as a mini HTML application to FILE.',
help_group=OUTPUT_GROUP,
sort_order=70),
]

def is_enabled(self, output_html_app, **kwargs):
return output_html_app
def is_enabled(self, html_app, **kwargs):
return html_app

def process_codebase(self, codebase,
input, # NOQA
output_html_app,
html_app,
scancode_version, **kwargs):

results = self.get_results(codebase, **kwargs)
output_html_app.write(as_html_app(output_html_app, input, scancode_version))
create_html_app_assets(results, output_html_app)
html_app.write(as_html_app(html_app, input, scancode_version))
create_html_app_assets(results, html_app)


def write_templated(output_file, results, version, template_or_format):
Expand Down
20 changes: 10 additions & 10 deletions src/formattedcode/output_spdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,49 +92,49 @@ def logger_debug(*args):
class SpdxTvOutput(OutputPlugin):

options = [
CommandLineOption(('--output-spdx-tv',),
CommandLineOption(('--spdx-tv',),
type=FileOptionType(mode='wb', lazy=False),
metavar='FILE',
requires=['info'],
help='Write scan output as SPDX Tag/Value to FILE.',
help_group=OUTPUT_GROUP)
]

def is_enabled(self, output_spdx_tv, info, **kwargs):
return output_spdx_tv and info
def is_enabled(self, spdx_tv, info, **kwargs):
return spdx_tv and info

def process_codebase(self, codebase,
input, # NOQA
output_spdx_tv,
spdx_tv,
scancode_version, scancode_notice, **kwargs):

results = self.get_results(codebase, **kwargs)
write_spdx(output_spdx_tv, results, scancode_version, scancode_notice,
write_spdx(spdx_tv, results, scancode_version, scancode_notice,
input, as_tagvalue=True)


@output_impl
class SpdxRdfOutput(OutputPlugin):

options = [
CommandLineOption(('--output-spdx-rdf',),
CommandLineOption(('--spdx-rdf',),
type=FileOptionType(mode='wb', lazy=False),
metavar='FILE',
requires=['info'],
help='Write scan output as SPDX RDF to FILE.',
help_group=OUTPUT_GROUP)
]

def is_enabled(self, output_spdx_rdf, info, **kwargs):
return output_spdx_rdf and info
def is_enabled(self, spdx_rdf, info, **kwargs):
return spdx_rdf and info

def process_codebase(self, codebase,
input, # NOQA
output_spdx_rdf,
spdx_rdf,
scancode_version, scancode_notice, **kwargs):

results = self.get_results(codebase, **kwargs)
write_spdx(output_spdx_rdf, results, scancode_version, scancode_notice,
write_spdx(spdx_rdf, results, scancode_version, scancode_notice,
input, as_tagvalue=False)


Expand Down
4 changes: 2 additions & 2 deletions src/scancode/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@
open 'scancode_result.html' in your web browser. Note that additional app files
are saved in a directory named 'scancode_result_files':
scancode --output-html-app scancode_result.html samples/
scancode --html-app scancode_result.html samples/
Scan a directory for licenses and copyrights. Save scan results to an
HTML file:
scancode --output-html scancode_result.html samples/zlib
scancode --html scancode_result.html samples/zlib
To extract archives, see the 'extractcode' command instead.
'''
Expand Down
6 changes: 3 additions & 3 deletions tests/formattedcode/test_output_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_csv_minimal():
test_dir = test_env.get_test_loc('csv/srp')
result_file = test_env.get_temp_file('csv')
expected_file = test_env.get_test_loc('csv/srp.csv')
args = ['--copyright', test_dir, '--output-csv', result_file]
args = ['--copyright', test_dir, '--csv', result_file]
run_scan_click(args)
check_csvs(result_file, expected_file)

Expand All @@ -201,15 +201,15 @@ def test_csv_tree():
test_dir = test_env.get_test_loc('csv/tree/scan')
result_file = test_env.get_temp_file('csv')
expected_file = test_env.get_test_loc('csv/tree/expected.csv')
args = ['--copyright', test_dir, '--output-csv', result_file]
args = ['--copyright', test_dir, '--csv', result_file]
run_scan_click(args)
check_csvs(result_file, expected_file)


def test_can_process_live_scan_with_all_options():
test_dir = test_env.get_test_loc('csv/livescan/scan')
result_file = test_env.get_temp_file('csv')
args = ['-clip', '--email', '--url', '--strip-root', test_dir, '--output-csv', result_file]
args = ['-clip', '--email', '--url', '--strip-root', test_dir, '--csv', result_file]
run_scan_plain(args)
expected_file = test_env.get_test_loc('csv/livescan/expected.csv')
check_csvs(result_file, expected_file)
Loading

0 comments on commit a4aba95

Please sign in to comment.