From 6d86b6b329d7db9ebfa94340a7655fd2202f0c84 Mon Sep 17 00:00:00 2001
From: Maeva Pourpoint <maeva@passcal.nmt.edu>
Date: Fri, 15 Mar 2024 11:52:32 -0600
Subject: [PATCH] Remove boilerplate code and associated tests that made each
 non-main module a standalone module

---
 nexus/ChannelSelectDialog.py | 17 -----------------
 nexus/NRLWizard.py           | 23 -----------------------
 nexus/hardware.py            |  6 ------
 nexus/inv_model.py           | 21 ---------------------
 nexus/inventorymodel.py      | 27 ---------------------------
 nexus/ms_sum.py              |  2 --
 6 files changed, 96 deletions(-)

diff --git a/nexus/ChannelSelectDialog.py b/nexus/ChannelSelectDialog.py
index 90621310..572c46ad 100644
--- a/nexus/ChannelSelectDialog.py
+++ b/nexus/ChannelSelectDialog.py
@@ -90,20 +90,3 @@ class ChannelSelectDialog(*load_ui('ChannelSelectDialog.ui')):
         assert True
         self.tableWidget.resizeColumnsToContents()
         self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)
-
-
-if __name__ == '__main__':
-    # Test
-    from obspy import read_inventory
-
-    inv = read_inventory('test/data/xml/XW.2017.dmc.xml')
-    sta = inv[0][0]
-
-    app = QApplication(sys.argv)
-    main = ChannelSelectDialog(station=sta)
-    if main.exec_():
-        print('Selected:')
-        for c in main.selected_channels:
-            print(c)
-    else:
-        print('Canceled')
diff --git a/nexus/NRLWizard.py b/nexus/NRLWizard.py
index 61c84c62..d361a01e 100644
--- a/nexus/NRLWizard.py
+++ b/nexus/NRLWizard.py
@@ -114,26 +114,3 @@ class NRLPage(QtWidgets.QWizardPage):
             self.parent.q_and_as.pop()
         except IndexError:
             pass
-
-
-if __name__ == '__main__':
-    import sys
-    app = QtWidgets.QApplication(sys.argv)
-
-    # Sensor
-    w = NRLWizard()
-    ret = w.exec_()
-    print(ret)
-    if ret:
-        print(w.q_and_as)
-        print(w.final)
-        print(w.nickname)
-        
-    # Datalogger
-    w = NRLWizard(DATALOGGER)
-    ret = w.exec_()
-    if ret:
-        print(w.q_and_as)
-        print(w.final)
-        print(w.nickname)
-    print(ret)
diff --git a/nexus/hardware.py b/nexus/hardware.py
index c255785d..0717ea10 100644
--- a/nexus/hardware.py
+++ b/nexus/hardware.py
@@ -262,9 +262,3 @@ def create_defaults():
                 with open(os.path.join(resp_dir, filename), 'r') as f:
                     d.soh_resps[chan] = read_inventory(
                         f, format='RESP')[0][0][0].response
-
-
-if __name__ == '__main__':
-    create_defaults()
-    print(sensors)
-    print(dataloggers)
diff --git a/nexus/inv_model.py b/nexus/inv_model.py
index d8549f19..340ede7d 100644
--- a/nexus/inv_model.py
+++ b/nexus/inv_model.py
@@ -36,24 +36,3 @@ class InventoryModel(QtCore.QAbstractListModel):
             station.end_date.year,
             station.end_date.julday,
             )
-
-if __name__ == '__main__':
-    app = QtWidgets.QApplication(sys.argv)
-
-    listview = QtWidgets.QListView()
-    listview.show()
-    listview.setFont(QtGui.QFont('Consolas',16))
-
-    treeview = QtWidgets.QTreeView()
-    treeview.show()
-    treeview.setFont(QtGui.QFont('Consolas',16))
-
-    inv = read_inventory('/Users/lloyd/code/nexus/nexuseis/test/data/'
-                               'ANDIVOLC.xml',
-                               format="STATIONXML")
-    inv_model = InventoryModel(inventory=inv)
-
-    listview.setModel(inv_model)
-    treeview.setModel(inv_model)
-
-    sys.exit(app.exec_())
diff --git a/nexus/inventorymodel.py b/nexus/inventorymodel.py
index 3b1dbcfe..acc5cf8c 100644
--- a/nexus/inventorymodel.py
+++ b/nexus/inventorymodel.py
@@ -127,30 +127,3 @@ class InventoryModel(QtCore.QAbstractItemModel):
         if parent == self._root_node:
             return QtCore.QModelIndex()
         return self.createIndex(parent.row(), 0, parent)
-
-
-if __name__ == '__main__':
-    app =  QtWidgets.QApplication(sys.argv)
-
-    root_node = Node('', None, None)
-
-    xx_node = Network('XX', None, root_node)
-    sta1_node = Station('STA1', None, xx_node)
-    chan1z_node = Channel('LHZ', None, sta1_node)
-    chan11_node = Channel('LH1', None, sta1_node)
-    chan12_node = Channel('LH2', None, sta1_node)
-    chan1log_node = Channel('LOG', None, sta1_node)
-    sta2_node = Station('STA2', None, xx_node)
-    chan2z_node = Channel('LHZ', None, sta2_node)
-    chan21 = Channel('LH1', None, sta2_node)
-    chan22_node = Channel('LH2', None, sta2_node)
-    chan2log_node = Channel('LOG', None, sta2_node)
-
-    print(root_node)
-
-    model = InventoryModel(root_node)
-    treeview = QtWidgets.QTreeView()
-    treeview.show()
-    treeview.setModel(model)
-
-    sys.exit(app.exec_())
diff --git a/nexus/ms_sum.py b/nexus/ms_sum.py
index d5ce8ef1..25cf0eee 100755
--- a/nexus/ms_sum.py
+++ b/nexus/ms_sum.py
@@ -25,5 +25,3 @@ def main():
             inv.scan_quick(path,log_message=lambda x:None)
     inv.print_sum()
 
-if __name__ == '__main__':
-    main()
-- 
GitLab