82 try: |
82 try: |
83 jsonString = json.dumps(stylesDict, indent=2) |
83 jsonString = json.dumps(stylesDict, indent=2) |
84 with open(filename, "w") as f: |
84 with open(filename, "w") as f: |
85 f.write(jsonString) |
85 f.write(jsonString) |
86 except (TypeError, OSError) as err: |
86 except (TypeError, OSError) as err: |
87 with E5OverridenCursor(): |
87 with EricOverridenCursor(): |
88 E5MessageBox.critical( |
88 EricMessageBox.critical( |
89 None, |
89 None, |
90 self.tr("Export Highlighting Styles"), |
90 self.tr("Export Highlighting Styles"), |
91 self.tr( |
91 self.tr( |
92 "<p>The highlighting styles file <b>{0}</b> could not" |
92 "<p>The highlighting styles file <b>{0}</b> could not" |
93 " be written.</p><p>Reason: {1}</p>" |
93 " be written.</p><p>Reason: {1}</p>" |
110 try: |
110 try: |
111 with open(filename, "r") as f: |
111 with open(filename, "r") as f: |
112 jsonString = f.read() |
112 jsonString = f.read() |
113 stylesDict = json.loads(jsonString) |
113 stylesDict = json.loads(jsonString) |
114 except (OSError, json.JSONDecodeError) as err: |
114 except (OSError, json.JSONDecodeError) as err: |
115 E5MessageBox.critical( |
115 EricMessageBox.critical( |
116 None, |
116 None, |
117 self.tr("Import Highlighting Styles"), |
117 self.tr("Import Highlighting Styles"), |
118 self.tr( |
118 self.tr( |
119 "<p>The highlighting styles file <b>{0}</b> could not be" |
119 "<p>The highlighting styles file <b>{0}</b> could not be" |
120 " read.</p><p>Reason: {1}</p>" |
120 " read.</p><p>Reason: {1}</p>" |