Fix modulation filter to check for multiple entries separated by

semicolon. Also add a check to remove duplicated signals when
loading the database from file
This commit is contained in:
alessandro90
2019-06-07 23:23:09 +02:00
parent 8cb81dd225
commit 8859495068
2 changed files with 7 additions and 4 deletions

View File

@@ -983,14 +983,13 @@ class Artemis(QMainWindow, Ui_MainWindow):
Populate the signals list and set the total number of signals. Populate the signals list and set the total number of signals.
Handle possible missing file error. Handle possible missing file error.
""" """
names = Database.NAMES
try: try:
self.db = read_csv(os.path.join(Constants.DATA_FOLDER, Database.NAME), self.db = read_csv(os.path.join(Constants.DATA_FOLDER, Database.NAME),
sep=Database.DELIMITER, sep=Database.DELIMITER,
header=None, header=None,
index_col=0, index_col=0,
dtype={name: str for name in Database.STRINGS}, dtype={name: str for name in Database.STRINGS},
names=names) names=Database.NAMES)
except FileNotFoundError: except FileNotFoundError:
self.search_bar.setDisabled(True) self.search_bar.setDisabled(True)
answer = pop_up(self, title=Messages.NO_DB, answer = pop_up(self, title=Messages.NO_DB,
@@ -1000,6 +999,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
if answer == QMessageBox.Yes: if answer == QMessageBox.Yes:
self.download_db() self.download_db()
else: else:
self.db = self.db.groupby(level=0).first()
self.signal_names = self.db.index self.signal_names = self.db.index
self.total_signals = len(self.signal_names) self.total_signals = len(self.signal_names)
self.db.fillna(Constants.UNKNOWN, inplace=True) self.db.fillna(Constants.UNKNOWN, inplace=True)
@@ -1019,7 +1019,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
) )
) )
def collect_list(self, list_property, separator=';'): def collect_list(self, list_property, separator=Constants.FIELD_SEPARATOR):
"""Collect all the entrys of a QListWidget. """Collect all the entrys of a QListWidget.
Handle multiple entries in one item seprated by a separator. Handle multiple entries in one item seprated by a separator.
@@ -1396,7 +1396,9 @@ class Artemis(QMainWindow, Ui_MainWindow):
if not self.apply_remove_modulation_filter_btn.isChecked(): if not self.apply_remove_modulation_filter_btn.isChecked():
return True return True
signal_modulation = [ signal_modulation = [
x.strip() for x in self.db.at[signal_name, Signal.MODULATION].split(',') x.strip() for x in self.db.at[
signal_name, Signal.MODULATION
].split(Constants.FIELD_SEPARATOR)
] ]
for item in self.modulation_list.selectedItems(): for item in self.modulation_list.selectedItems():
if item.text() in signal_modulation: if item.text() in signal_modulation:

View File

@@ -176,6 +176,7 @@ class Constants:
EXTRACTING_CODE = -1 EXTRACTING_CODE = -1
NOT_AVAILABLE = "spectrumnotavailable.png" NOT_AVAILABLE = "spectrumnotavailable.png"
NOT_SELECTED = "nosignalselected.png" NOT_SELECTED = "nosignalselected.png"
FIELD_SEPARATOR = ";"
DEFAULT_IMGS_FOLDER = os.path.join(":", "pics", "default_pics") DEFAULT_IMGS_FOLDER = os.path.join(":", "pics", "default_pics")
DEFAULT_NOT_SELECTED = os.path.join(DEFAULT_IMGS_FOLDER, NOT_SELECTED) DEFAULT_NOT_SELECTED = os.path.join(DEFAULT_IMGS_FOLDER, NOT_SELECTED)
DEFAULT_NOT_AVAILABLE = os.path.join(DEFAULT_IMGS_FOLDER, NOT_AVAILABLE) DEFAULT_NOT_AVAILABLE = os.path.join(DEFAULT_IMGS_FOLDER, NOT_AVAILABLE)