[tor-commits] [sbws/master] Add method to find bw of a node

juga at torproject.org juga at torproject.org
Tue Sep 18 09:26:11 UTC 2018


commit 02f0f815829ae483f441c7c563965e5899bcac99
Author: juga0 <juga at riseup.net>
Date:   Fri Aug 31 13:58:23 2018 +0000

    Add method to find bw of a node
    
    useful to combine data when plotting
---
 sbws/lib/v3bwfile.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 04699c6..545cd77 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -724,6 +724,16 @@ class V3BWFile(object):
     def median_bw(self):
         return median([l.bw for l in self.bw_lines])
 
+    def bw_line_for_node_id(self, node_id):
+        """Returns the bandwidth line for a given node fingerprint.
+
+        Used to combine data when plotting.
+        """
+        bwl = [l for l in self.bw_lines if l.node_id == node_id]
+        if bwl:
+            return bwl[0]
+        return None
+
     def to_plt(self, attrs=['bw'], sorted_by=None):
         """Return bandwidth data in a format useful for matplotlib.
 





More information about the tor-commits mailing list