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

[tor-commits] [compass/master] Merge AS_Number and AS_Name



commit 3042bb95f008b3fb0345076c95039261f041a3ed
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date:   Tue Aug 28 19:28:51 2012 +0530

    Merge AS_Number and AS_Name
    
    Those two columns took up quite a bit of space, merging
    them together should hopefully free up more space to
    display more important information.
---
 app.py                |    2 ++
 compass.py            |   11 ++++++-----
 templates/result.html |    6 ++----
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/app.py b/app.py
index 40de2fa..a0d2b05 100644
--- a/app.py
+++ b/app.py
@@ -39,6 +39,7 @@ class Result():
         self.cc = None
         self.as_no = None
         self.as_name = None
+        self.as_info = None
 
 def parse(output_string, grouping=False, sort_key=None):
     results = []
@@ -78,6 +79,7 @@ def parse(output_string, grouping=False, sort_key=None):
             result.as_no = values[10]
             result.as_name = ' '.join(values[11:])
             result.as_name = re.sub(r'\([^)]*\)', '', result.as_name)
+            result.as_info = "%s %s" % (result.as_no, result.as_name)
 
             if sort_key:
                 key = float(getattr(result, sort_key)[:-1])
diff --git a/compass.py b/compass.py
index e478e8f..015e71a 100755
--- a/compass.py
+++ b/compass.py
@@ -251,6 +251,7 @@ class RelayStats(object):
                 country = relay.get('country', '??')
                 as_number = relay.get('as_number', '??')
                 as_name = relay.get('as_name', '??')
+                as_info = "%s %s" %(as_number, as_name)
                 relays_in_group += 1
             if by_country or by_as_number:
                 nickname = "*"
@@ -263,9 +264,9 @@ class RelayStats(object):
                 if not by_country and not country:
                     country = "*"
             if links:
-                format_string = "%8.4f%% %8.4f%% %8.4f%% %8.4f%% %8.4f%% %-19s %-78s %-4s %-5s %-2s %-9s %s"
+                format_string = "%8.4f%% %8.4f%% %8.4f%% %8.4f%% %8.4f%% %-19s %-78s %-4s %-5s %-2s %-9s"
             else:
-                format_string = "%8.4f%% %8.4f%% %8.4f%% %8.4f%% %8.4f%% %-19s %-40s %-4s %-5s %-2s %-9s %s"
+                format_string = "%8.4f%% %8.4f%% %8.4f%% %8.4f%% %8.4f%% %-19s %-40s %-4s %-5s %-2s %-9s"
             formatted_group = format_string % (
                               group_weights[0] * 100.0,
                               group_weights[1] * 100.0,
@@ -273,7 +274,7 @@ class RelayStats(object):
                               group_weights[3] * 100.0,
                               group_weights[4] * 100.0,
                               nickname, fingerprint,
-                              exit, guard, country, as_number, as_name)
+                              exit, guard, country, as_info)
             formatted_groups[formatted_group] = group_weights
         sorted_groups = sorted(formatted_groups.iteritems(), key=operator.itemgetter(1))
         sorted_groups.reverse()
@@ -282,9 +283,9 @@ class RelayStats(object):
     def print_groups(self, sorted_groups, count=10, by_country=False, by_as_number=False, short=False, links=False):
         output_string = []
         if links:
-            output_string.append("       CW    adv_bw   P_guard  P_middle    P_exit Nickname            Link                                                                           Exit Guard CC AS_num    AS_name"[:short])
+            output_string.append("       CW    adv_bw   P_guard  P_middle    P_exit Nickname            Link                                                                           Exit Guard CC Autonomous System"[:short])
         else:
-            output_string.append("       CW    adv_bw   P_guard  P_middle    P_exit Nickname            Fingerprint                              Exit Guard CC AS_num    AS_name"[:short])
+            output_string.append("       CW    adv_bw   P_guard  P_middle    P_exit Nickname            Fingerprint                              Exit Guard CC Autonomous System"[:short])
         if count < 0: count = len(sorted_groups)
         for formatted_group, weight in sorted_groups[:count]:
             output_string.append(formatted_group[:short])
diff --git a/templates/result.html b/templates/result.html
index a572933..28d4f21 100644
--- a/templates/result.html
+++ b/templates/result.html
@@ -63,8 +63,7 @@
               <th>Exit</th>
               <th>Guard</th>
               <th>Country</th>
-              <th>Autonomous System Number</th>
-              <th>Autonomous System Name</th>
+              <th>Autonomous System</th>
             </tr>
           </thead>
           <tbody>
@@ -87,8 +86,7 @@
               <td>{{ result.exit }}</td>
               <td>{{ result.guard }}</td>
               <td>{{ result.cc }}</td>
-              <td>{{ result.as_no }}</td>
-              <td>{{ result.as_name }}</td>
+              <td>{{ result.as_info }}</td>
             </tr>
            {% endfor %}
           </tbody>



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