Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
integrated the new verbosity approach.

Options:
  --overwrite          Overwrites the output file if it exists
  --verbosity INTEGER  Print more or fewer verbose messages while
processing
                       ABOUT files (Default: 30)
                       50 - CRITICAL
                       40 - ERROR
                       30 -
                       WARNING
                       20 - INFO
                       10 - DEBUG
  --help               Show this message and exit.
  • Loading branch information
chinyeungli committed Apr 4, 2016
1 parent ed7c017 commit 870609b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions about_code_tool/cmd.py
Expand Up @@ -54,6 +54,7 @@

prog_name = 'AboutCode'
no_stdout = False
msg_verbosity = 30

intro = '''%(prog_name)s, version %(__version__)s
ABOUT spec version: %(__about_spec_version__)s http://dejacode.org
Expand Down Expand Up @@ -100,7 +101,14 @@ def cli(verbose, quiet):
type=click.Path(exists=False, file_okay=True, writable=True,
dir_okay=False, resolve_path=True))
@click.option('--overwrite', is_flag=True, help='Overwrites the output file if it exists')
def inventory(overwrite, location, output):
@click.option('--verbosity', default=30,
help='Print more or fewer verbose messages while processing ABOUT files (Default: 30)\n'
'50 - CRITICAL\n'
'40 - ERROR\n'
'30 - WARNING\n'
'20 - INFO\n'
'10 - DEBUG')
def inventory(overwrite, verbosity, location, output):
"""
Inventory components from an ABOUT file or a directory tree of ABOUT
files.
Expand All @@ -123,6 +131,9 @@ def inventory(overwrite, location, output):

click.echo('Collecting the inventory from location: ''%(location)s '
'and writing CSV output to: %(output)s' % locals())

global msg_verbosity
msg_verbosity = verbosity

errors, abouts = about_code_tool.model.collect_inventory(location)
log_errors(errors)
Expand Down Expand Up @@ -243,11 +254,12 @@ def log_errors(errors, base_dir=False, level=NOTSET):
file_handler = logging.FileHandler(log_path)
file_logger.addHandler(file_handler)
for severity, message in errors:
sever = about_code_tool.severities[severity]
if not no_stdout:
print(msg_format % locals())
if base_dir:
file_logger.log(30, msg_format % locals())
if severity >= msg_verbosity:
sever = about_code_tool.severities[severity]
if not no_stdout:
print(msg_format % locals())
if base_dir:
file_logger.log(30, msg_format % locals())


if __name__ == '__main__':
Expand Down

0 comments on commit 870609b

Please sign in to comment.