Added capability to read/write tasks file of eric 5.2 line of development. 5_1_x

Sun, 27 Mar 2011 17:51:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 27 Mar 2011 17:51:17 +0200
branch
5_1_x
changeset 962
88b386d26b74
parent 959
3b5ad7224945
child 964
144c0383344e

Added capability to read/write tasks file of eric 5.2 line of development.

DTDs/Tasks-5.0.dtd file | annotate | diff | comparison | revisions
E5XML/Config.py file | annotate | diff | comparison | revisions
E5XML/TasksReader.py file | annotate | diff | comparison | revisions
E5XML/TasksWriter.py file | annotate | diff | comparison | revisions
Tasks/TaskViewer.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DTDs/Tasks-5.0.dtd	Sun Mar 27 17:51:17 2011 +0200
@@ -0,0 +1,29 @@
+<!-- This is the DTD for eric5's tasks file version 5.0 -->
+
+<!ELEMENT   Summary             (#PCDATA)>
+
+<!ELEMENT   Description         (#PCDATA)>
+
+<!ELEMENT   Created             (#PCDATA)>
+
+<!ELEMENT   Filename            (#PCDATA)>
+
+<!ELEMENT   Linenumber          (#PCDATA)>
+
+<!ELEMENT   Resource            (Filename, Linenumber)>
+
+<!ELEMENT   Task                (Summary,
+                                 Description,
+                                 Created,
+                                 Resource?)>
+<!ATTLIST   Task
+    priority    CDATA   #REQUIRED
+    completed   CDATA   #REQUIRED
+    bugfix      CDATA   #IMPLIED>
+
+<!ELEMENT   ProjectScanFilter   (#PCDATA)>
+
+<!ELEMENT   Tasks               (ProjectScanFilter?,
+                                 Task*)>
+<!ATTLIST   Tasks
+    version     CDATA   #REQUIRED>
--- a/E5XML/Config.py	Sun Mar 27 12:23:30 2011 +0200
+++ b/E5XML/Config.py	Sun Mar 27 17:51:17 2011 +0200
@@ -24,6 +24,7 @@
 
 # version number of the tasks file
 tasksFileFormatVersion = "4.2"
+tasksFileFormatVersionAlternative = "5.0"
 
 # version number of the debugger properties file
 debuggerPropertiesFileFormatVersion = "3.9"
--- a/E5XML/TasksReader.py	Sun Mar 27 12:23:30 2011 +0200
+++ b/E5XML/TasksReader.py	Sun Mar 27 17:51:17 2011 +0200
@@ -20,7 +20,7 @@
     """
     Class for reading an XML tasks file.
     """
-    supportedVersions = ["4.2"]
+    supportedVersions = ["4.2", "5.0"]
     
     def __init__(self, device, forProject = False, viewer = None):
         """
@@ -55,6 +55,10 @@
                         self.raiseUnsupportedFormatVersion(self.version)
                 elif self.name() == "Task":
                     self.__readTask()
+                elif self.name() == "ProjectScanFilter":
+                    filter = self.readElementText()
+                    if self.forProject:
+                        self.viewer.projectTasksScanFilter = filter
                 else:
                     self.raiseUnexpectedStartTag(self.name())
         
--- a/E5XML/TasksWriter.py	Sun Mar 27 12:23:30 2011 +0200
+++ b/E5XML/TasksWriter.py	Sun Mar 27 17:51:17 2011 +0200
@@ -12,7 +12,7 @@
 from E5Gui.E5Application import e5App
 
 from .XMLStreamWriterBase import XMLStreamWriterBase
-from .Config import tasksFileFormatVersion
+from .Config import tasksFileFormatVersion, tasksFileFormatVersionAlternative
 
 import Preferences
 import Utilities
@@ -38,10 +38,15 @@
         """
         Public method to write the XML to the file.
         """
+        viewer = e5App().getObject("TaskViewer")
+        
         XMLStreamWriterBase.writeXML(self)
         
+        formatVersion = tasksFileFormatVersion
+        if self.forProject and viewer.projectTasksScanFilter is not None:
+            formatVersion = tasksFileFormatVersionAlternative
         self.writeDTD('<!DOCTYPE Tasks SYSTEM "Tasks-{0}.dtd">'.format(
-            tasksFileFormatVersion))
+            formatVersion))
         
         # add some generation comments
         if self.forProject:
@@ -57,11 +62,16 @@
         self.writeStartElement("Tasks")
         self.writeAttribute("version", tasksFileFormatVersion)
         
+        # write the project scan filter
+        if self.forProject and viewer.projectTasksScanFilter is not None:
+            self.writeTextElement("ProjectScanFilter",
+                e5App().getObject("TaskViewer").projectTasksScanFilter.strip())
+        
         # do the tasks
         if self.forProject:
-            tasks = e5App().getObject("TaskViewer").getProjectTasks()
+            tasks = viewer.getProjectTasks()
         else:
-            tasks = e5App().getObject("TaskViewer").getGlobalTasks()
+            tasks = viewer.getGlobalTasks()
         for task in tasks:
             self.writeStartElement("Task")
             self.writeAttribute("priority", str(task.priority))
--- a/Tasks/TaskViewer.py	Sun Mar 27 12:23:30 2011 +0200
+++ b/Tasks/TaskViewer.py	Sun Mar 27 17:51:17 2011 +0200
@@ -360,6 +360,7 @@
         self.copyTask = None
         self.projectOpen = False
         self.project = project
+        self.projectTasksScanFilter = None
         
         self.taskFilter = TaskFilter()
         self.taskFilter.setActive(False)
@@ -805,4 +806,4 @@
         """
         Private method to open the configuration dialog.
         """
-        e5App().getObject("UserInterface").showPreferences("tasksPage")
\ No newline at end of file
+        e5App().getObject("UserInterface").showPreferences("tasksPage")

eric ide

mercurial