From d1b53fe549fc2040d8a490dd19e232a0517703fb Mon Sep 17 00:00:00 2001
From: Mattia Mancini <mancini@astron.nl>
Date: Mon, 4 Jun 2018 08:28:49 +0000
Subject: [PATCH] Story SW-300: cleaning up code to adhere to pep standards

---
 LCU/Maintenance/MDB_tools/cli/probe_mdb.py | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/LCU/Maintenance/MDB_tools/cli/probe_mdb.py b/LCU/Maintenance/MDB_tools/cli/probe_mdb.py
index af88827db49..6bcbe8589b2 100644
--- a/LCU/Maintenance/MDB_tools/cli/probe_mdb.py
+++ b/LCU/Maintenance/MDB_tools/cli/probe_mdb.py
@@ -105,9 +105,9 @@ def get_query_string_for_time_limit(from_date, to_date):
             else:
                 date = to_date
 
-            query += '&start_time__year__lte=%d' % (date.year)
-            query += '&start_time__month__lte=%d' % (date.month)
-            query += '&start_time__day__lte=%d' % (date.day)
+            query += '&start_time__year__lte=%d' % (date.year,)
+            query += '&start_time__month__lte=%d' % (date.month,)
+            query += '&start_time__day__lte=%d' % (date.day,)
 
         except ValueError:
             logger.error('format of to date not valid; YYYY-MM-DD es. 2016-15-12')
@@ -190,17 +190,18 @@ def reformat_values(item):
         return str(item)
 
 
-def print_out_station_test_summary(station_test, id):
+def print_out_station_test_summary(station_test, idx):
     """
     Prints the summary of the station test
     :param station_test: dict containing the results of the station test
+    :param idx: index of the current station test
     :return:
     """
     summary_fields = ['station_name', 'station_type', 'start_time', 'end_time', 'performed_checks']
     summary_header = ['Name', 'Type', 'Start', 'End', 'Checks']
     values = [reformat_values(station_test[item]) for item in summary_fields]
     print()
-    print('Station test #{}'.format(id))
+    print('Station test #{}'.format(idx))
     table_width = 200
     terminal = blessings.Terminal()
     if terminal.does_styling:
@@ -275,8 +276,8 @@ def print_out_component_errors(station_test):
 
         tile_errors = error.get('tile_errors', None)
         if tile_errors:
-            for i, tile_error in enumerate(tile_errors):
-                tile_error_string = 'Tile error #{} on tile id {}'.format(i, tile_error['tile_id'])
+            for k, tile_error in enumerate(tile_errors):
+                tile_error_string = 'Tile error #{} on tile id {}'.format(k, tile_error['tile_id'])
                 print(tile_error_indentation + tile_error_string)
                 print(tile_error_indentation + '-' * len(tile_error_string))
 
@@ -294,7 +295,7 @@ def rtsm_sort_errors(errors):
         rcu
         time
 
-    :param component_errors:
+    :param errors: RTSM errors to be sorted
     :return:
     """
     sorted_components = sorted(errors, key=itemgetter('rcu', 'error_type', 'time'))
@@ -313,11 +314,10 @@ def print_out_rtsm_summary(rtsm_results):
         table_width = terminal.width
     table = beautifultable.BeautifulTable(max_width=table_width)
     header = ['observation_id', 'station_name', 'start_time', 'end_time',
-              'component_id', 'error_type','start_frequency', 'stop_frequency',
+              'component_id', 'error_type', 'start_frequency', 'stop_frequency',
               'mode', 'percentage']
-    table.column_headers = ['observation_id', 'station_name', 'start_time', 'end_time',
-                            'component_id', 'error_type','start_frequency', 'stop_frequency',
-                            'mode', 'percentage']
+    table.column_headers = header
+
     for rtsm_result in sorted(rtsm_results, key=itemgetter('observation_id')):
         obs_id = rtsm_result['observation_id']
         station_name = rtsm_result['station_name']
-- 
GitLab