src/eric7/Tasks/TasksFile.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/Tasks/TasksFile.py
--- a/src/eric7/Tasks/TasksFile.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Tasks/TasksFile.py	Wed Jul 13 14:55:47 2022 +0200
@@ -25,10 +25,11 @@
     """
     Class representing the tasks JSON file.
     """
+
     def __init__(self, isGlobal: bool, parent: QObject = None):
         """
         Constructor
-        
+
         @param isGlobal flag indicating a file for global tasks
         @type bool
         @param parent reference to the parent object (defaults to None)
@@ -36,11 +37,11 @@
         """
         super().__init__(parent)
         self.__isGlobal = isGlobal
-    
+
     def writeFile(self, filename: str) -> bool:
         """
         Public method to write the tasks data to a tasks JSON file.
-        
+
         @param filename name of the tasks file
         @type str
         @return flag indicating a successful write
@@ -52,14 +53,12 @@
         if self.__isGlobal:
             tasksDict["header"] = {
                 "comment": "eric tasks file",
-                "saved": time.strftime('%Y-%m-%d, %H:%M:%S'),
-                "warning": (
-                    "This file was generated automatically, do not edit."
-                ),
+                "saved": time.strftime("%Y-%m-%d, %H:%M:%S"),
+                "warning": ("This file was generated automatically, do not edit."),
             }
             # step 1: project scan filter
             tasksDict["ProjectScanFilter"] = ""
-            
+
             # step 2: tasks
             tasksDict["Tasks"] = [
                 task.toDict()
@@ -68,26 +67,23 @@
         else:
             tasksDict["header"] = {
                 "comment": "eric tasks file for project {0}".format(
-                    ericApp().getObject("Project").getProjectName()),
-                "warning": (
-                    "This file was generated automatically, do not edit."
+                    ericApp().getObject("Project").getProjectName()
                 ),
+                "warning": ("This file was generated automatically, do not edit."),
             }
             if Preferences.getProject("TimestampFile"):
-                tasksDict["header"]["saved"] = (
-                    time.strftime('%Y-%m-%d, %H:%M:%S')
-                )
+                tasksDict["header"]["saved"] = time.strftime("%Y-%m-%d, %H:%M:%S")
             # step 1: project scan filter
             tasksDict["ProjectScanFilter"] = (
                 ericApp().getObject("TaskViewer").getTasksScanFilter()
             )
-            
+
             # step 2: tasks
             tasksDict["Tasks"] = [
                 task.toDict()
                 for task in ericApp().getObject("TaskViewer").getProjectTasks()
             ]
-        
+
         try:
             jsonString = json.dumps(tasksDict, indent=2)
             with open(filename, "w") as f:
@@ -100,16 +96,16 @@
                     self.tr(
                         "<p>The tasks file <b>{0}</b> could not be"
                         " written.</p><p>Reason: {1}</p>"
-                    ).format(filename, str(err))
+                    ).format(filename, str(err)),
                 )
                 return False
-        
+
         return True
-    
+
     def readFile(self, filename: str) -> bool:
         """
         Public method to read the tasks data from a task JSON file.
-        
+
         @param filename name of the project file
         @type str
         @return flag indicating a successful read
@@ -126,28 +122,33 @@
                 self.tr(
                     "<p>The tasks file <b>{0}</b> could not be read.</p>"
                     "<p>Reason: {1}</p>"
-                ).format(filename, str(err))
+                ).format(filename, str(err)),
             )
             return False
-        
+
         viewer = ericApp().getObject("TaskViewer")
         if tasksDict["ProjectScanFilter"]:
             viewer.setTasksScanFilter(tasksDict["ProjectScanFilter"])
-        
+
         addedTasks = []
         for task in tasksDict["Tasks"]:
             addedTask = viewer.addTask(
-                task["summary"], priority=TaskPriority(task["priority"]),
-                filename=task["filename"], lineno=task["lineno"],
-                completed=task["completed"], _time=task["created"],
+                task["summary"],
+                priority=TaskPriority(task["priority"]),
+                filename=task["filename"],
+                lineno=task["lineno"],
+                completed=task["completed"],
+                _time=task["created"],
                 isProjectTask=not self.__isGlobal,
                 taskType=TaskType(task["type"]),
-                description=task["description"], uid=task["uid"],
-                parentTask=task["parent_uid"])
+                description=task["description"],
+                uid=task["uid"],
+                parentTask=task["parent_uid"],
+            )
             if addedTask:
                 addedTasks.append((addedTask, task["expanded"]))
-        
+
         for task, expanded in addedTasks:
             task.setExpanded(expanded)
-        
+
         return True

eric ide

mercurial