eric6/Project/ProjectFile.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 8125
9e789fa8f38e
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de>
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a class representing the project JSON file.
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import json
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import time
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import typing
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt5.QtCore import QObject
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui import E5MessageBox
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui.E5OverrideCursor import E5OverridenCursor
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import Preferences
8107
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
20 import Utilities
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
8015
09b24828d787 Cprrected the use of the typing module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8012
diff changeset
22 Project = typing.TypeVar("Project")
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class ProjectFile(QObject):
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class representing the project JSON file.
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 def __init__(self, project: Project, parent: QObject = None):
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param project reference to the project object
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type Project
8016
e484fc67677e Corrected some code documentation strings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8015
diff changeset
35 @param parent reference to the parent object (defaults to None)
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type QObject (optional)
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 super(ProjectFile, self).__init__(parent)
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__project = project
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 def writeFile(self, filename: str) -> bool:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 Public method to write the project data to a project JSON file.
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param filename name of the project file
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @type str
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @return flag indicating a successful write
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @rtype bool
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 projectDict = {}
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 projectDict["header"] = {
8012
ecf45f723038 Several corrections to the JSON file handlers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8006
diff changeset
52 "comment": "eric project file for project {0}".format(
ecf45f723038 Several corrections to the JSON file handlers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8006
diff changeset
53 self.__project.getProjectName()),
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 "copyright": "Copyright (C) {0} {1}, {2}".format(
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 time.strftime('%Y'),
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__project.pdata["AUTHOR"],
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__project.pdata["EMAIL"])
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 }
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
8031
ce5858a237d2 Changed the Project and MultiProject configuration option "XMLTimestamp" to "TimestampFile". A configuration check is suggested.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8016
diff changeset
60 if Preferences.getProject("TimestampFile"):
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 projectDict["header"]["saved"] = (
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 time.strftime('%Y-%m-%d, %H:%M:%S')
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 )
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 projectDict["project"] = self.__project.pdata
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
8107
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
67 # modify paths to contain universal separators
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
68 for key in (
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
69 "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS",
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
70 "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS"
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
71 ):
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
72 try:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
73 projectDict["project"][key] = [
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
74 Utilities.fromNativeSeparators(f)
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
75 for f in projectDict["project"][key]
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
76 ]
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
77 except KeyError:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
78 # ignore non-existent elements
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
79 pass
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
80 for key in (
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
81 "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN",
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
82 "TRANSLATIONSBINPATH", "MAINSCRIPT"
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
83 ):
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
84 try:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
85 projectDict["project"][key] = Utilities.fromNativeSeparators(
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
86 projectDict["project"][key])
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
87 except KeyError:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
88 # ignore non-existent elements
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
89 pass
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
90
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 try:
8125
9e789fa8f38e Saving the project file with sorted dictionary keys to get more stability into it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8107
diff changeset
92 jsonString = json.dumps(projectDict, indent=2, sort_keys=True)
8107
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
93 with open(filename, "w", newline="") as f:
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 f.write(jsonString)
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 except (TypeError, EnvironmentError) as err:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 with E5OverridenCursor():
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 E5MessageBox.critical(
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 None,
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.tr("Save Project File"),
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.tr(
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 "<p>The project file <b>{0}</b> could not be "
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 "written.</p><p>Reason: {1}</p>"
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 ).format(filename, str(err))
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 )
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 return False
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 return True
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def readFile(self, filename: str) -> bool:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 Public method to read the project data from a project JSON file.
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @param filename name of the project file
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @type str
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @return flag indicating a successful read
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @rtype bool
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 try:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 with open(filename, "r") as f:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 jsonString = f.read()
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 projectDict = json.loads(jsonString)
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 except (EnvironmentError, json.JSONDecodeError) as err:
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 E5MessageBox.critical(
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 None,
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.tr("Read Project File"),
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.tr(
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 "<p>The project file <b>{0}</b> could not be "
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 "read.</p><p>Reason: {1}</p>"
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 ).format(filename, str(err))
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 )
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 return False
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
8107
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
133 # modify paths to contain native separators
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
134 for key in (
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
135 "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS",
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
136 "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS"
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
137 ):
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
138 try:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
139 projectDict["project"][key] = [
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
140 Utilities.toNativeSeparators(f)
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
141 for f in projectDict["project"][key]
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
142 ]
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
143 except KeyError:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
144 # ignore non-existent elements
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
145 pass
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
146 for key in (
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
147 "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN",
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
148 "TRANSLATIONSBINPATH", "MAINSCRIPT"
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
149 ):
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
150 try:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
151 projectDict["project"][key] = Utilities.toNativeSeparators(
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
152 projectDict["project"][key])
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
153 except KeyError:
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
154 # ignore non-existent elements
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
155 pass
7d3932bde11b ProjectFile: changed paths handling to work with different platforms.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8031
diff changeset
156
8006
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.__project.pdata = projectDict["project"]
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
c4110b8b5931 Started converting the various file generators to JSON format (from XML).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 return True

eric ide

mercurial