Skip to content

Commit

Permalink
Make reports multi-file friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
gkisel committed Dec 30, 2014
1 parent e87febf commit 56ce6fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions prospector/formatters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class TextFormatter(Formatter):
summary_labels = (
('path', 'Path'),
('started', 'Started'),
('completed', 'Finished'),
('time_taken', 'Time Taken', lambda x: '%s seconds' % x),
Expand Down
9 changes: 7 additions & 2 deletions prospector/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def process_messages(self, messages):
def execute(self):

summary = {
'path': self.path,
'started': datetime.now(),
'libraries': self.libraries,
'strictness': self.strictness,
Expand Down Expand Up @@ -284,10 +285,12 @@ def print_messages(self, write_to=None):
self.summary['formatter'] = output_format
formatter = FORMATTERS[output_format](self.summary, self.messages)

print_messages = not self.config.summary_only and self.messages

# Produce the output
write_to.write(formatter.render(
summary=not self.config.messages_only,
messages=not self.config.summary_only,
messages=print_messages,
))
write_to.write('\n')

Expand Down Expand Up @@ -320,10 +323,12 @@ def main():
'not directories.')

# Make it so
messages = []
for path in paths:
prospector = Prospector(config, path)
prospector.execute()
prospector.print_messages()
messages.extend(prospector.get_messages())

if config.zero_exit:
# if we ran successfully, and the user wants us to, then we'll
Expand All @@ -333,7 +338,7 @@ def main():
# otherwise, finding messages is grounds for exiting with an error
# code, to make it easier for bash scripts and similar situations
# to know if there any errors have been found.
if len(prospector.get_messages()) > 0:
if len(messages) > 0:
return 1
return 0

Expand Down

0 comments on commit 56ce6fa

Please sign in to comment.