61 time.strftime('%Y-%m-%d, %H:%M:%S') |
62 time.strftime('%Y-%m-%d, %H:%M:%S') |
62 ) |
63 ) |
63 |
64 |
64 projectDict["project"] = self.__project.pdata |
65 projectDict["project"] = self.__project.pdata |
65 |
66 |
|
67 # modify paths to contain universal separators |
|
68 for key in ( |
|
69 "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS", |
|
70 "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS" |
|
71 ): |
|
72 try: |
|
73 projectDict["project"][key] = [ |
|
74 Utilities.fromNativeSeparators(f) |
|
75 for f in projectDict["project"][key] |
|
76 ] |
|
77 except KeyError: |
|
78 # ignore non-existent elements |
|
79 pass |
|
80 for key in ( |
|
81 "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN", |
|
82 "TRANSLATIONSBINPATH", "MAINSCRIPT" |
|
83 ): |
|
84 try: |
|
85 projectDict["project"][key] = Utilities.fromNativeSeparators( |
|
86 projectDict["project"][key]) |
|
87 except KeyError: |
|
88 # ignore non-existent elements |
|
89 pass |
|
90 |
66 try: |
91 try: |
67 jsonString = json.dumps(projectDict, indent=2) |
92 jsonString = json.dumps(projectDict, indent=2) |
68 with open(filename, "w") as f: |
93 with open(filename, "w", newline="") as f: |
69 f.write(jsonString) |
94 f.write(jsonString) |
70 except (TypeError, EnvironmentError) as err: |
95 except (TypeError, EnvironmentError) as err: |
71 with E5OverridenCursor(): |
96 with E5OverridenCursor(): |
72 E5MessageBox.critical( |
97 E5MessageBox.critical( |
73 None, |
98 None, |
103 "read.</p><p>Reason: {1}</p>" |
128 "read.</p><p>Reason: {1}</p>" |
104 ).format(filename, str(err)) |
129 ).format(filename, str(err)) |
105 ) |
130 ) |
106 return False |
131 return False |
107 |
132 |
|
133 # modify paths to contain native separators |
|
134 for key in ( |
|
135 "SOURCES", "FORMS", "TRANSLATIONS", "TRANSLATIONEXCEPTIONS", |
|
136 "RESOURCES", "INTERFACES", "PROTOCOLS", "OTHERS" |
|
137 ): |
|
138 try: |
|
139 projectDict["project"][key] = [ |
|
140 Utilities.toNativeSeparators(f) |
|
141 for f in projectDict["project"][key] |
|
142 ] |
|
143 except KeyError: |
|
144 # ignore non-existent elements |
|
145 pass |
|
146 for key in ( |
|
147 "SPELLWORDS", "SPELLEXCLUDES", "TRANSLATIONPATTERN", |
|
148 "TRANSLATIONSBINPATH", "MAINSCRIPT" |
|
149 ): |
|
150 try: |
|
151 projectDict["project"][key] = Utilities.toNativeSeparators( |
|
152 projectDict["project"][key]) |
|
153 except KeyError: |
|
154 # ignore non-existent elements |
|
155 pass |
|
156 |
108 self.__project.pdata = projectDict["project"] |
157 self.__project.pdata = projectDict["project"] |
109 |
158 |
110 return True |
159 return True |