Skip to content

Commit 98417b4

Browse files
author
Julia Eskew
authored
Merge pull request #28 from edx/juliasq/date_fix_annotation_num_return
Add prefixing of report filename. Change elapsed time to seconds.
2 parents 5e401ca + 102233f commit 98417b4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

code_annotations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
from __future__ import absolute_import, unicode_literals
66

7-
__version__ = '0.2.3'
7+
__version__ = '0.2.4'

code_annotations/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,20 +570,23 @@ def _format_results_for_report(self, all_results):
570570

571571
return formatted_results
572572

573-
def report(self, all_results):
573+
def report(self, all_results, report_prefix=''):
574574
"""
575575
Genrates the YAML report of all search results.
576576
577577
Args:
578578
all_results: Dict of found annotations, indexed by filename
579+
report_prefix: Prefix to add to report filename
579580
580581
Returns:
581582
Filename of generated report
582583
"""
583584
self.echo.echo_vv(yaml.dump(all_results, default_flow_style=False))
584585

585586
now = datetime.datetime.now()
586-
report_filename = os.path.join(self.config.report_path, '{}.yaml'.format(now.strftime('%Y-%d-%m-%H-%M-%S')))
587+
report_filename = os.path.join(self.config.report_path, '{}{}.yaml'.format(
588+
report_prefix, now.strftime('%Y-%d-%m-%H-%M-%S')
589+
))
587590

588591
formatted_results = self._format_results_for_report(all_results)
589592

code_annotations/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def entry_point():
3939
show_default=True,
4040
help='List all locally defined models (in the current repo) that require annotations.',
4141
)
42+
@click.option('--app_name', default='', help='(Optional) App name for which coverage is generated.')
4243
@click.option('--report_path', default=None, help='Location to write the report')
4344
@click.option('-v', '--verbosity', count=True, help='Verbosity level (-v through -vvv)')
4445
@click.option('--lint/--no_lint', help='Enable or disable linting checks', default=False, show_default=True)
@@ -48,6 +49,7 @@ def django_find_annotations(
4849
config_file,
4950
seed_safelist,
5051
list_local_models,
52+
app_name,
5153
report_path,
5254
verbosity,
5355
lint,
@@ -96,15 +98,17 @@ def django_find_annotations(
9698
click.echo("Coverage passed without errors.")
9799

98100
if report:
99-
searcher.report(annotated_models)
101+
searcher.report(annotated_models, app_name)
100102

101103
annotation_count = 0
102104

103105
for filename in annotated_models:
104106
annotation_count += len(annotated_models[filename])
105107

106108
elapsed = datetime.datetime.now() - start_time
107-
click.echo("Search found {} annotations in {}.".format(annotation_count, elapsed))
109+
click.echo("Search found {} annotations in {} seconds.".format(
110+
annotation_count, elapsed.total_seconds()
111+
))
108112

109113
except Exception as exc: # pylint: disable=broad-except
110114
click.echo(traceback.print_exc())

0 commit comments

Comments
 (0)