Skip to content

Commit

Permalink
🐛 fix plural message. fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Jun 11, 2018
1 parent d37d912 commit d46b08c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions moban/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def report_no_action():

def report_full_run(file_count):
figure = crayons.green(str(file_count), bold=True)
print(MESSAGE_TEMPLATED_ALL.format(figure))
message = MESSAGE_TEMPLATED_ALL.format(figure)
print(_format_single(message, file_count))


def report_partial_run(file_count, total):
figure = crayons.green(str(file_count), bold=True)
total_figure = crayons.yellow(str(total), bold=True)
print(MESSAGE_REPORT.format(figure, total_figure))
message = MESSAGE_REPORT.format(figure, total_figure)
print(_format_single(message, total))


def report_error_message(message):
Expand Down Expand Up @@ -65,4 +67,11 @@ def report_no_copying_done():

def report_copying_summary(file_count):
figure = crayons.green(str(file_count), bold=True)
print(MESSAGE_COPIED_ALL.format(figure))
message = MESSAGE_COPIED_ALL.format(figure)
print(_format_single(message, file_count))


def _format_single(message, count):
if count == 1:
return message.replace('files', 'file')
return message
6 changes: 6 additions & 0 deletions tests/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ def test_no_action():
reporter.report_no_action()
patcher.stop()
eq_(fake_stdout.getvalue(), "No templating\n")


def test_format_single():
message = '1 files'
ret = reporter._format_single(message, 1)
eq_(ret, '1 file')

0 comments on commit d46b08c

Please sign in to comment.