Skip to content

Commit

Permalink
Merge pull request #189 from nodedge/fix/dats_recent_files
Browse files Browse the repository at this point in the history
Resolves #183: Do not add log file to recent file if format is not su…
  • Loading branch information
nodedge committed Apr 23, 2023
2 parents 7ed17ce + fc352d6 commit 3490c8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion nodedge/dats/dats_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ def replaceCurve(self, oldName, newName):
self.plotCurves([newName])

def deleteCurve(self):

worksheetTabWidget = self.workbooksTabWidget.currentWidget()
nPlotWidget = worksheetTabWidget.currentWidget()
if not nPlotWidget.items:
Expand Down Expand Up @@ -715,6 +714,17 @@ def addToRecentFiles(self, filepath):
:param filepath: absolute path and filename of the file to open.
:type filepath: ``str``
"""
extension = os.path.splitext(filepath)[1]
if extension.lower() not in [
".mf4",
".mdf4",
".csv",
".mat",
".txt",
".hdf5",
".h5",
]:
return
if filepath in self.recentFiles:
self.recentFiles.remove(filepath)
self.recentFiles.insert(0, filepath)
Expand Down
3 changes: 1 addition & 2 deletions nodedge/dats/logs_list_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def openLog(self, filename) -> Optional[MDF]:
if extension.lower() == "mf4":
log = MDF(filename)
elif extension.lower() in ["csv", "txt"]:
with open(filename, "r") as f:
with open(filename) as f:
line = f.readline()
separator = ","
if "," not in line:
Expand Down Expand Up @@ -212,7 +212,6 @@ def addLog(self, log, shortname, prependDate=True):

def addLogs(self, logs, prependDate=True):
for logName, log in logs.items():

self.addLog(log, logName, prependDate)

def onItemClicked(self, item):
Expand Down

0 comments on commit 3490c8a

Please sign in to comment.