From 29cdbf72b86ad76a609cfb391609b847d6412729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Martano?= Date: Sat, 10 May 2014 10:40:00 -0300 Subject: [PATCH] Allow round to INT In round_dict, if places is None, round to INT. --- i3pystatus/core/util.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/i3pystatus/core/util.py b/i3pystatus/core/util.py index e0b05ba..65af494 100644 --- a/i3pystatus/core/util.py +++ b/i3pystatus/core/util.py @@ -50,9 +50,14 @@ def partition(iterable, limit, key=lambda x: x): def round_dict(dic, places): """ Rounds all values in a dict containing only numeric types to `places` decimal places. - """ - for key, value in dic.items(): - dic[key] = round(value, places) + If places is None, round to INT. + """ + if places is None: + for key, value in dic.items(): + dic[key] = round(value) + else: + for key, value in dic.items(): + dic[key] = round(value, places) class ModuleList(collections.UserList):