[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Drop log panel's is_duplicate() helper



commit 871912cb14edf81a5695bd54b0356331eed2e702
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Apr 12 15:29:14 2015 -0700

    Drop log panel's is_duplicate() helper
    
    It no longer really does much. Despite its name is wasn't being used check for
    a boolean condition, but rather get the indices of duplicates. Merging it with
    its sole caller.
---
 nyx/log_panel.py |   50 +++++++++++---------------------------------------
 1 file changed, 11 insertions(+), 39 deletions(-)

diff --git a/nyx/log_panel.py b/nyx/log_panel.py
index cdb2346..dc63af8 100644
--- a/nyx/log_panel.py
+++ b/nyx/log_panel.py
@@ -169,8 +169,17 @@ def get_duplicates(events):
   return_events = []
 
   while events_remaining:
-    entry = events_remaining.pop(0)
-    duplicate_indices = is_duplicate(entry, events_remaining, True)
+    entry, duplicate_indices = events_remaining.pop(0), []
+
+    for i, earlier_entry in enumerate(events_remaining):
+      # if showing dates then do duplicate detection for each day, rather
+      # than globally
+
+      if earlier_entry.type == DAYBREAK_EVENT:
+        break
+
+      if entry.is_duplicate(earlier_entry):
+        duplicate_indices.append(i)
 
     # checks if the call timeout has been reached
 
@@ -192,43 +201,6 @@ def get_duplicates(events):
   return return_events
 
 
-def is_duplicate(event, event_set, get_duplicates = False):
-  """
-  True if the event is a duplicate for something in the event_set, false
-  otherwise. If the get_duplicates flag is set this provides the indices of
-  the duplicates instead.
-
-  Arguments:
-    event         - event to search for duplicates of
-    event_set      - set to look for the event in
-    get_duplicates - instead of providing back a boolean this gives a list of
-                    the duplicate indices in the event_set
-  """
-
-  duplicate_indices = []
-
-  for i in range(len(event_set)):
-    forward_entry = event_set[i]
-
-    # if showing dates then do duplicate detection for each day, rather
-    # than globally
-
-    if forward_entry.type == DAYBREAK_EVENT:
-      break
-
-    if event.type == forward_entry.type:
-      if event.is_duplicate(forward_entry):
-        if get_duplicates:
-          duplicate_indices.append(i)
-        else:
-          return True
-
-  if get_duplicates:
-    return duplicate_indices
-  else:
-    return False
-
-
 class LogPanel(panel.Panel, threading.Thread, logging.Handler):
   """
   Listens for and displays tor, nyx, and stem events. This can prepopulate



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits