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

[tor-commits] [nyx/master] Move get_locale() out of the Endpoint class



commit f67a50d10981ce2840d00c02cb62844290e2dcc1
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Jul 25 19:45:55 2015 -0700

    Move get_locale() out of the Endpoint class
    
    We only ever care about the remote endpoint, so might as well move this to the
    line class. One step closer to axing the Endpoint entirely.
---
 nyx/connections/conn_entry.py |   18 +++++++++---------
 nyx/connections/conn_panel.py |    2 +-
 nyx/connections/entries.py    |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/nyx/connections/conn_entry.py b/nyx/connections/conn_entry.py
index d0ff8dc..fd066e5 100644
--- a/nyx/connections/conn_entry.py
+++ b/nyx/connections/conn_entry.py
@@ -67,13 +67,6 @@ class Endpoint:
 
     self.fingerprint_overwrite = None
 
-  def get_locale(self, default = None):
-    """
-    Provides the two letter country code of this relay.
-    """
-
-    return tor_controller().get_info('ip-to-country/%s' % self._address, default)
-
   def get_fingerprint(self, default = None):
     """
     Provides the fingerprint of this relay.
@@ -184,6 +177,13 @@ class ConnectionLine(entries.ConnectionPanelLine):
     self.sort_address = ip_value
     self.sort_port = self.connection.remote_port
 
+  def get_locale(self, default = None):
+    """
+    Provides the two letter country code for the remote endpoint.
+    """
+
+    return tor_controller().get_info('ip-to-country/%s' % self.connection.remote_address, default)
+
   def get_listing_entry(self, width, current_time, listing_type):
     """
     Provides the tuple list for this connection's listing. Lines are composed
@@ -601,7 +601,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
 
     lines = [''] * 7
     lines[0] = 'address: %s' % self.get_destination_label(width - 11)
-    lines[1] = 'locale: %s' % ('??' if self.is_private() else self.foreign.get_locale('??'))
+    lines[1] = 'locale: %s' % ('??' if self.is_private() else self.get_locale('??'))
 
     # Remaining data concerns the consensus results, with three possible cases:
     # - if there's a single match then display its details
@@ -777,7 +777,7 @@ class ConnectionLine(entries.ConnectionPanelLine):
         controller = tor_controller()
 
         if include_locale and not controller.is_geoip_unavailable():
-          foreign_locale = self.foreign.get_locale('??')
+          foreign_locale = self.get_locale('??')
           extra_info.append(foreign_locale)
           space_available -= len(foreign_locale) + 2
 
diff --git a/nyx/connections/conn_panel.py b/nyx/connections/conn_panel.py
index 193ec90..51f22a8 100644
--- a/nyx/connections/conn_panel.py
+++ b/nyx/connections/conn_panel.py
@@ -485,7 +485,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
         entry_line = entry.get_lines()[0]
 
         if entry_line.is_private() and entry_line.get_type() == conn_entry.Category.INBOUND:
-          client_locale = entry_line.foreign.get_locale()
+          client_locale = entry_line.get_locale(None)
 
           if client_locale:
             self._client_locale_usage[client_locale] = self._client_locale_usage.get(client_locale, 0) + 1
diff --git a/nyx/connections/entries.py b/nyx/connections/entries.py
index 06d3831..228b172 100644
--- a/nyx/connections/entries.py
+++ b/nyx/connections/entries.py
@@ -149,7 +149,7 @@ class ConnectionPanelEntry:
       if connection_line.connection.is_private_address(self.lines[0].connection.remote_address):
         return ''
       else:
-        return connection_line.foreign.get_locale('')
+        return connection_line.get_locale('')
     elif attr == SortAttr.LISTING:
       if listing_type == ListingType.IP_ADDRESS:
         # uses the IP address as the primary value, and port as secondary



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