未验证 提交 054597be 编写于 作者: N Nicolas Hennion 提交者: GitHub

Merge pull request #1873 from metayan/fix-history-add

Fix history_add, so it allows history_max_size to be zero
......@@ -21,7 +21,6 @@
from datetime import datetime
class GlancesAttribute(object):
def __init__(self, name, description='', history_max_size=None):
......@@ -105,10 +104,10 @@ class GlancesAttribute(object):
def history_add(self, value):
"""Add a value in the history
"""
if not (self._history_max_size is None or self.history_len() < self._history_max_size):
#self._history = self._history[1:] + [value]
self._history.pop(0)
self._history.append(value)
if self._history_max_size:
if self.history_len() >= self._history_max_size:
self._history.pop(0)
self._history.append(value)
def history_size(self):
"""Return the history size (maximum nuber of value in the history)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册