From 4d8277c5c222aec251a0b22d3252b50f02666bae Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Mon, 8 Apr 2024 16:25:25 +0200 Subject: [PATCH] Pamhyr2: Fix pep8. --- src/View/AdditionalFiles/UndoCommand.py | 2 ++ src/View/AdditionalFiles/Window.py | 1 + src/View/REPLines/UndoCommand.py | 2 ++ src/tools.py | 10 ++++++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/View/AdditionalFiles/UndoCommand.py b/src/View/AdditionalFiles/UndoCommand.py index ba417ff6..631c91fa 100644 --- a/src/View/AdditionalFiles/UndoCommand.py +++ b/src/View/AdditionalFiles/UndoCommand.py @@ -48,6 +48,7 @@ class SetCommand(QUndoCommand): for key in self._new: f[key] = self._new[key] + class AddCommand(QUndoCommand): def __init__(self, files, row): QUndoCommand.__init__(self) @@ -65,6 +66,7 @@ class AddCommand(QUndoCommand): else: self._files.insert(self._row, self._new) + class DelCommand(QUndoCommand): def __init__(self, files, row): QUndoCommand.__init__(self) diff --git a/src/View/AdditionalFiles/Window.py b/src/View/AdditionalFiles/Window.py index c6c22522..eabb35e7 100644 --- a/src/View/AdditionalFiles/Window.py +++ b/src/View/AdditionalFiles/Window.py @@ -28,6 +28,7 @@ from View.AdditionalFiles.List import ListModel from View.AdditionalFiles.Translate import AddFileTranslate from View.AdditionalFiles.Edit.Window import EditAddFileWindow + class AddFileListWindow(PamhyrWindow): _pamhyr_ui = "AdditionalFileList" _pamhyr_name = "Additional files" diff --git a/src/View/REPLines/UndoCommand.py b/src/View/REPLines/UndoCommand.py index 7618c207..80988671 100644 --- a/src/View/REPLines/UndoCommand.py +++ b/src/View/REPLines/UndoCommand.py @@ -48,6 +48,7 @@ class SetCommand(QUndoCommand): for key in self._new: f[key] = self._new[key] + class AddCommand(QUndoCommand): def __init__(self, lines, row): QUndoCommand.__init__(self) @@ -65,6 +66,7 @@ class AddCommand(QUndoCommand): else: self._lines.insert(self._row, self._new) + class DelCommand(QUndoCommand): def __init__(self, lines, row): QUndoCommand.__init__(self) diff --git a/src/tools.py b/src/tools.py index 35ed7b40..422fcdd6 100644 --- a/src/tools.py +++ b/src/tools.py @@ -234,14 +234,19 @@ def timestamp(dt: datetime): return (dt - datetime(1970, 1, 1)).total_seconds() return dt.timestamp() + def date_iso_to_timestamp(date: str): - return datetime.isoformat(date) + if type(date) is str: + return datetime.fromisoformat(date).timestamp() + else: + return datetime.isoformat(date) + def date_dmy_to_timestamp(date: str): if date.count(":") == 0: ret = datetime.strptime(date, "%d/%m/%y") elif date.count(".") == 1: - ret= datetime.strptime(date, "%d/%m/%y %H:%M:%S.%f") + ret = datetime.strptime(date, "%d/%m/%y %H:%M:%S.%f") elif date.count(":") == 1: ret = datetime.strptime(date, "%d/%m/%y %H:%M") elif date.count(":") == 2: @@ -251,6 +256,7 @@ def date_dmy_to_timestamp(date: str): return ret.timestamp() + def old_pamhyr_date_to_timestamp(date: str): v = date.split(":") if len(v) != 4: -- GitLab