diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-07-04 15:41:10 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-05 09:44:45 +0000 |
commit | 4ff8764e76331836ca9e20d505786c365372309c (patch) | |
tree | 93a72be71f5175bd8a615a78e3ef36f80824332a | |
parent | 282a4fcbd1c114a3f38c062f0780fc69d0a80343 (diff) | |
download | buildstream-4ff8764e76331836ca9e20d505786c365372309c.tar.gz |
_messenger: refactor, pythonic _message_depth
Use some Python features to make Messenger._message_depth a bit simpler.
-rw-r--r-- | src/buildstream/_messenger.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/buildstream/_messenger.py b/src/buildstream/_messenger.py index cb5051595..a440bfe5a 100644 --- a/src/buildstream/_messenger.py +++ b/src/buildstream/_messenger.py @@ -19,7 +19,6 @@ import os import datetime -from collections import deque from contextlib import contextmanager from . import _signals @@ -33,7 +32,7 @@ class Messenger(): def __init__(self): self._message_handler = None - self._message_depth = deque() + self._message_depth = [] self._log_handle = None self._log_filename = None @@ -58,10 +57,7 @@ class Messenger(): # (bool): Whether messages are currently being silenced # def _silent_messages(self): - for silent in self._message_depth: - if silent: - return True - return False + return any(self._message_depth) # message(): # @@ -75,7 +71,7 @@ class Messenger(): # Tag message only once if message.depth is None: - message.depth = len(list(self._message_depth)) + message.depth = len(self._message_depth) # If we are recording messages, dump a copy into the open log file. self._record_message(message) @@ -290,8 +286,8 @@ class Messenger(): # activities inside a given task through the message # def _push_message_depth(self, silent_nested): - self._message_depth.appendleft(silent_nested) + self._message_depth.append(silent_nested) def _pop_message_depth(self): assert self._message_depth - self._message_depth.popleft() + self._message_depth.pop() |