Skip to content

Commit 8370c0d

Browse files
committed
Remove the --validate-about-resource option #306
* Remove the `--validate-about-resource` option * Update USAGE doc * Rename `ignore_about_resource_path_error` to `ignore_about_resource_path_not_exist_error` Signed-off-by: Chin Yeung Li <[email protected]>
1 parent cfa5986 commit 8370c0d

File tree

4 files changed

+10
-52
lines changed

4 files changed

+10
-52
lines changed

USAGE.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ attrib
4545
names - mapping.config
4646
--show-all Show all the errors and warning
4747
--template PATH Path to a custom attribution template.
48-
--validate-about-resource Validate the existence of the about resource.
4948
-q, --quiet Do not print any error/warning.
5049
--help Show this message and exit.
5150

@@ -94,10 +93,6 @@ Options
9493
For instance, if user has a custom template located at:
9594
/home/custom_template/template.html
9695

97-
--validate-about-resource
98-
99-
The option ask the tool to validate the existence of the referencing file.
100-
10196
$ about attrib --template /home/custom_template/template.html LOCATION OUTPUT
10297

10398

@@ -178,7 +173,6 @@ gen
178173
--mapping Use for mapping between the input keys and
179174
the ABOUT field names - mapping.config
180175
--show-all Show all the errors and warning
181-
--validate-about-resource Validate the existence of the about resource.
182176
-q, --quiet Do not print any error/warning.
183177
--help Show this message and exit.
184178

@@ -224,9 +218,6 @@ Options
224218
This option ask the tool to show all kind of errors found.
225219
The default behavior will only show 'CRITICAL', 'ERROR', and 'WARNING'
226220

227-
--validate-about-resource
228-
229-
The option ask the tool to validate the existence of the referencing file.
230221

231222
inventory
232223
=========
@@ -247,7 +238,6 @@ inventory
247238
-f, --format [json|csv] Set OUTPUT file format. [default: csv]
248239
--mapping Use file mapping.config to collect the defined not supported fields in ABOUT files.
249240
--show-all Show all the errors and warning
250-
--validate-about-resource Validate the existence of the about resource.
251241
-q, --quiet Do not print any error/warning.
252242
--help Show this message and exit.
253243

@@ -273,8 +263,4 @@ Options
273263
This option ask the tool to show all kind of errors found.
274264
The default behavior will only show 'CRITICAL', 'ERROR', and 'WARNING'
275265

276-
--validate-about-resource
277-
278-
The option ask the tool to validate the existence of the referencing file.
279-
280266
$ about inventory -f json [OPTIONS] LOCATION OUTPUT

src/attributecode/cmd.py

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from attributecode import model
3636
from attributecode import severities
3737
from attributecode.util import extract_zip
38-
from attributecode.util import ignore_about_resource_path_error
38+
from attributecode.util import ignore_about_resource_path_not_exist_error
3939
from attributecode.util import to_posix
4040

4141

@@ -123,16 +123,12 @@ def cli():
123123
'for any level.'
124124
)
125125

126-
@click.option('--validate-about-resource', is_flag=True, default=False,
127-
help='Validate the existence of the about resource.'
128-
)
129-
130126
@click.option('-q', '--quiet', is_flag=True,
131127
help='Do not print error or warning messages.')
132128

133129
@click.help_option('-h', '--help')
134130

135-
def inventory(location, output, mapping, quiet, format, show_all, validate_about_resource):
131+
def inventory(location, output, mapping, quiet, format, show_all):
136132
"""
137133
Collect a JSON or CSV inventory of components from .ABOUT files.
138134
@@ -161,13 +157,8 @@ def inventory(location, output, mapping, quiet, format, show_all, validate_about
161157
for err in write_errors:
162158
errors.append(err)
163159

164-
finalized_errors = []
160+
finalized_errors = ignore_about_resource_path_not_exist_error(errors)
165161

166-
if not validate_about_resource:
167-
finalized_errors = ignore_about_resource_path_error(errors)
168-
else:
169-
finalized_errors = errors
170-
171162
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
172163
sys.exit(0)
173164

@@ -212,17 +203,13 @@ def inventory(location, output, mapping, quiet, format, show_all, validate_about
212203
'for any level.'
213204
)
214205

215-
@click.option('--validate-about-resource', is_flag=True, default=False,
216-
help='Validate the existence of the about resource.'
217-
)
218-
219206
@click.option('-q', '--quiet', is_flag=True,
220207
help='Do not print error or warning messages.')
221208

222209
@click.help_option('-h', '--help')
223210

224211
def gen(location, output, mapping, license_notice_text_location, fetch_license,
225-
quiet, show_all, validate_about_resource):
212+
quiet, show_all):
226213
"""
227214
Generate .ABOUT files in OUTPUT directory from a JSON or CSV inventory of .ABOUT files at LOCATION.
228215
@@ -244,12 +231,7 @@ def gen(location, output, mapping, license_notice_text_location, fetch_license,
244231

245232
about_count = len(abouts)
246233
error_count = 0
247-
finalized_errors = []
248-
249-
if not validate_about_resource:
250-
finalized_errors = ignore_about_resource_path_error(errors)
251-
else:
252-
finalized_errors = errors
234+
finalized_errors = ignore_about_resource_path_not_exist_error(errors)
253235

254236
for e in finalized_errors:
255237
# Only count as warning/error if CRITICAL, ERROR and WARNING
@@ -295,17 +277,12 @@ def gen(location, output, mapping, license_notice_text_location, fetch_license,
295277
@click.option('--template', type=click.Path(exists=True), nargs=1,
296278
help='Path to an optional custom attribution template used for generation.')
297279

298-
@click.option('--validate-about-resource', is_flag=True, default=False,
299-
help='Validate the existence of the about resource.'
300-
)
301-
302280
@click.option('-q', '--quiet', is_flag=True,
303281
help='Do not print error or warning messages.')
304282

305283
@click.help_option('-h', '--help')
306284

307-
def attrib(location, output, template, mapping, inventory, quiet, show_all,
308-
validate_about_resource):
285+
def attrib(location, output, template, mapping, inventory, quiet, show_all):
309286
"""
310287
Generate an attribution document at OUTPUT using .ABOUT files at LOCATION.
311288
@@ -337,12 +314,7 @@ def attrib(location, output, template, mapping, inventory, quiet, show_all,
337314
for no_match_error in no_match_errors:
338315
inv_errors.append(no_match_error)
339316

340-
finalized_errors = []
341-
342-
if not validate_about_resource:
343-
finalized_errors = ignore_about_resource_path_error(inv_errors)
344-
else:
345-
finalized_errors = inv_errors
317+
finalized_errors = ignore_about_resource_path_not_exist_error(inv_errors)
346318

347319
log_errors(finalized_errors, quiet, show_all, os.path.dirname(output))
348320
click.echo('Finished.')

src/attributecode/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def copy_license_notice_files(fields, base_dir, license_notice_text_location, af
473473
shutil.copy2(from_lic_path, to_lic_path)
474474

475475

476-
def ignore_about_resource_path_error(errors):
476+
def ignore_about_resource_path_not_exist_error(errors):
477477
ignore_resource_path_check_message = u'Field about_resource_path:'
478478
updated_errors = []
479479
for err in errors:

tests/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@ def test_apply_mapping(self):
339339
])]
340340
assert util.apply_mapping(input) == expected
341341

342-
def test_ignore_about_resource_path_error(self):
342+
def test_ignore_about_resource_path_not_exist_error(self):
343343
input_err = [Error(ERROR, 'Field about_resource_path: test.tar.gz does not exist'),
344344
Error(ERROR, 'Field about_resource_path: test.tar.gz does not exist')]
345345
expected_err = []
346-
assert util.ignore_about_resource_path_error(input_err) == expected_err
346+
assert util.ignore_about_resource_path_not_exist_error(input_err) == expected_err

0 commit comments

Comments
 (0)