Skip to content

Commit 66cc43d

Browse files
committed
minor change to UpsList __str__
1 parent f51b975 commit 66cc43d

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

UPSmodules/UPSmodule.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,17 @@ def __repr__(self) -> str:
645645
def __str__(self) -> str:
646646
num_ups = self.num_upss()
647647

648-
def num_is_are(num: int) -> Tuple[int, str]:
649-
return num, 'are' if num != 1 else 'is'
648+
def num_is_are(num: int, singular: str = 'is', plural: str = 'are') -> Tuple[int, str]:
649+
""" Return a tuple of amount and appropriate singular/plural word.
650650
651-
out_str = '{} {} listed in {}.\n'.format(num_ups['total'], 'UPS' if num_ups['total'] == 1 else 'UPSs',
651+
:param num: Amount of whatever
652+
:param singular: word for singular use
653+
:param plural: word for plural use
654+
:return: tuple of quantity and appropriate word
655+
"""
656+
return num, plural if num != 1 else singular
657+
658+
out_str = '{} {} listed in {}.\n'.format(*num_is_are(num_ups['total'], 'UPS', 'UPSs'),
652659
env.UT_CONST.ups_json_file)
653660
out_str += ' {} {} compatible, {} {} accessible, {} {} responsive, '\
654661
'{} {} valid, and {} {} daemon.\n'.format(*num_is_are(num_ups['compatible']),

0 commit comments

Comments
 (0)