From 4691a53589824cca7f4f7c8e84ef15fe76f6b382 Mon Sep 17 00:00:00 2001 From: Iliyas Jorio Date: Sat, 8 Mar 2014 19:48:58 +0100 Subject: [PATCH] mem: allow standard float formatting syntax Floats in mem.py can now be formatted with a standard format string (e.g. {avail_mem:.2f}) instead of needing an extra `round` parameter. This brings this module in line with the expected behavior in the rest of i3pystatus. --- README.rst | 1 - i3pystatus/mem.py | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 2fd4dac..d86be46 100644 --- a/README.rst +++ b/README.rst @@ -542,7 +542,6 @@ Settings: :color: standard color (default: ``#00FF00``) :warn_color: defines the color used wann warn percentage ist exceeded (default: ``#FFFF00``) :alert_color: defines the color used when alert percentage is exceeded (default: ``#FF0000``) -:round: round byte values to given length behind dot diff --git a/i3pystatus/mem.py b/i3pystatus/mem.py index 5de8d31..6546bc6 100644 --- a/i3pystatus/mem.py +++ b/i3pystatus/mem.py @@ -23,7 +23,6 @@ class Mem(IntervalModule): alert_color = "#FF0000" warn_percentage = 50 alert_percentage = 80 - _round = 2 settings = ( ("format", "format string used for output."), @@ -36,7 +35,6 @@ class Mem(IntervalModule): "defines the color used wann warn percentage ist exceeded"), ("alert_color", "defines the color used when alert percentage is exceeded"), - ("round", "round byte values to given length behind dot") ) def run(self): @@ -53,10 +51,9 @@ class Mem(IntervalModule): self.output = { "full_text": self.format.format( - used_mem=round(used / self.divisor, self._round), - avail_mem=round(memory_usage.available / self.divisor, - self._round), - total_mem=round(memory_usage.total / self.divisor, self._round), - percent_used_mem=int(memory_usage.percent)), + used_mem=used / self.divisor, + avail_mem=memory_usage.available / self.divisor, + total_mem=memory_usage.total / self.divisor, + percent_used_mem=memory_usage.percent), "color":color }