jp (cmd/roster): fixes division by zero exceptions
fix bug 135
This commit is contained in:
parent
046fb62a52
commit
4408147e2d
1 changed files with 10 additions and 2 deletions
|
|
@ -149,8 +149,16 @@ class Stats(base.CommandBase):
|
|||
print "Contacts with no subscription at all: %d" % no_sub
|
||||
print
|
||||
print "Total number of groups: %d" % len(unique_groups)
|
||||
print "Average contacts per group: %.1f" % (float(total_group_subscription) / len(unique_groups))
|
||||
print "Average groups' subscriptions per contact: %.1f" % (float(total_group_subscription) / len(contacts))
|
||||
try:
|
||||
contacts_per_group = float(total_group_subscription) / len(unique_groups)
|
||||
except ZeroDivisionError:
|
||||
contacts_per_group = 0
|
||||
print "Average contacts per group: {:.1f}".format(contacts_per_group)
|
||||
try:
|
||||
groups_per_contact = float(total_group_subscription) / len(contacts)
|
||||
except ZeroDivisionError:
|
||||
groups_per_contact = 0
|
||||
print "Average groups' subscriptions per contact: {:.1f}".format(groups_per_contact)
|
||||
print "Contacts not assigned to any group: %d" % no_group
|
||||
self.host.quit()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue