[tor-commits] [nyx/master] filter() provides an iterater rather than a list
atagar at torproject.org
atagar at torproject.org
Sun Aug 28 18:29:22 UTC 2016
commit de061785bed2a92fff2f82e30ce73ef6050df09b
Author: Damian Johnson <atagar at torproject.org>
Date: Sun Aug 28 10:19:06 2016 -0700
filter() provides an iterater rather than a list
Standardizing most of our filter() calls to provide us a list...
AttributeError: 'filter' object has no attribute 'append'
---
nyx/curses.py | 2 +-
nyx/panel/config.py | 2 +-
nyx/panel/log.py | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/nyx/curses.py b/nyx/curses.py
index 922729c..d6176f9 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -511,7 +511,7 @@ def asci_to_curses(msg):
continue
elif attr in Color:
# replace previous color with new one
- combined_attr = filter(lambda attr: attr not in Color, combined_attr)
+ combined_attr = list(filter(lambda attr: attr not in Color, combined_attr))
combined_attr.append(attr)
diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index 424586c..3a4a67b 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -294,7 +294,7 @@ class ConfigPanel(nyx.panel.Panel):
break
def _get_config_options(self):
- return self._contents if self._show_all else filter(lambda entry: stem.manual.is_important(entry.name) or entry.is_set(), self._contents)
+ return self._contents if self._show_all else list(filter(lambda entry: stem.manual.is_important(entry.name) or entry.is_set(), self._contents))
def _draw_line(subwindow, x, y, entry, is_selected, value_width, description_width):
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index ec9e238..af793aa 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -72,7 +72,7 @@ class LogPanel(nyx.panel.DaemonPanel):
logged_events = CONFIG['startup.events'].split(',')
tor_events = tor_controller().get_info('events/names', '').split()
- invalid_events = filter(lambda event: not event.startswith('NYX_') and event not in tor_events, logged_events)
+ invalid_events = list(filter(lambda event: not event.startswith('NYX_') and event not in tor_events, logged_events))
if invalid_events:
logged_events = ['NOTICE', 'WARN', 'ERR', 'NYX_NOTICE', 'NYX_WARNING', 'NYX_ERROR']
@@ -270,8 +270,8 @@ class LogPanel(nyx.panel.DaemonPanel):
show_duplicates = self._show_duplicates
event_log = self._event_log_paused if nyx_controller.is_paused() else self._event_log
- event_log = filter(lambda entry: event_filter.match(entry.display_message), event_log)
- event_log = filter(lambda entry: not entry.is_duplicate or show_duplicates, event_log)
+ event_log = list(filter(lambda entry: event_filter.match(entry.display_message), event_log))
+ event_log = list(filter(lambda entry: not entry.is_duplicate or show_duplicates, event_log))
is_scrollbar_visible = last_content_height > subwindow.height - 1
More information about the tor-commits
mailing list