Skip to content

Commit ef8f9e9

Browse files
committed
#481 - Add Excel support as input for gen
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent df7f85f commit ef8f9e9

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Add new option to choose extract license from ScanCode LicenseDB or DJC License Library
1515
* Add ability to transform Excel formatted file
1616
* Generate attribution directly from CSV/JSON/Excel file
17+
* Generate ABOUT files with excel as an input
1718

1819
2021-04-02
1920
Release 6.0.0

src/attributecode/cmd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def inventory(location, output, format, quiet, verbose): # NOQA
199199

200200

201201
@about.command(cls=AboutCommand,
202-
short_help='Generate .ABOUT files from an inventory as CSV or JSON.')
202+
short_help='Generate .ABOUT files from an inventory as CSV/JSON/Excel.')
203203

204204
@click.argument('location',
205205
required=True,
@@ -245,9 +245,9 @@ def inventory(location, output, format, quiet, verbose): # NOQA
245245
@click.help_option('-h', '--help')
246246
def gen(location, output, android, fetch_license, fetch_license_djc, reference, quiet, verbose):
247247
"""
248-
Given a CSV/JSON inventory, generate ABOUT files in the output location.
248+
Given a CSV/JSON/Excel inventory, generate ABOUT files in the output location.
249249
250-
LOCATION: Path to a JSON or CSV inventory file.
250+
LOCATION: Path to a JSON/CSV/Excel inventory file.
251251
252252
OUTPUT: Path to a directory where ABOUT files are generated.
253253
"""
@@ -256,8 +256,8 @@ def gen(location, output, android, fetch_license, fetch_license_djc, reference,
256256
click.echo('Generating .ABOUT files...')
257257

258258
# FIXME: This should be checked in the `click`
259-
if not location.endswith(('.csv', '.json',)):
260-
raise click.UsageError('ERROR: Invalid input file extension: must be one .csv or .json.')
259+
if not location.endswith(('.csv', '.json', '.xlsx')):
260+
raise click.UsageError('ERROR: Invalid input file extension: must be one .csv or .json or .xlsx.')
261261

262262
errors, abouts = generate_about_files(
263263
location=location,
@@ -297,7 +297,7 @@ def validate_template(ctx, param, value):
297297

298298

299299
@about.command(cls=AboutCommand,
300-
short_help='Generate an attribution document from .ABOUT files.')
300+
short_help='Generate an attribution document from JSON/CSV/Excel/.ABOUT files.')
301301

302302
@click.argument('input',
303303
required=True,

tests/testdata/test_cmd/help/about_gen_help.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Usage: about gen [OPTIONS] LOCATION OUTPUT
22

3-
Given a CSV/JSON inventory, generate ABOUT files in the output location.
3+
Given a CSV/JSON/Excel inventory, generate ABOUT files in the output location.
44

5-
LOCATION: Path to a JSON or CSV inventory file.
5+
LOCATION: Path to a JSON/CSV/Excel inventory file.
66

77
OUTPUT: Path to a directory where ABOUT files are generated.
88

tests/testdata/test_cmd/help/about_help.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ Options:
1313
-h, --help Show this message and exit.
1414

1515
Commands:
16-
attrib Generate an attribution document from .ABOUT files.
16+
attrib Generate an attribution document from
17+
JSON/CSV/Excel/.ABOUT files.
1718
check Validate that the format of .ABOUT files is correct and
1819
report errors and warnings.
1920
collect-redist-src Collect redistributable sources.
20-
gen Generate .ABOUT files from an inventory as CSV or JSON.
21+
gen Generate .ABOUT files from an inventory as CSV/JSON/Excel.
2122
inventory Collect the inventory of .ABOUT files to a CSV or JSON
2223
file.
2324
transform Transform a CSV/JSON/Excel by applying renamings, filters

0 commit comments

Comments
 (0)