eric7/Preferences/HighlightingStylesFile.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8318
962bce857696
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
10 import json 10 import json
11 import time 11 import time
12 12
13 from PyQt6.QtCore import QObject 13 from PyQt6.QtCore import QObject
14 14
15 from E5Gui import E5MessageBox 15 from E5Gui import EricMessageBox
16 from E5Gui.E5OverrideCursor import E5OverridenCursor 16 from E5Gui.EricOverrideCursor import EricOverridenCursor
17 17
18 import Preferences 18 import Preferences
19 19
20 20
21 class HighlightingStylesFile(QObject): 21 class HighlightingStylesFile(QObject):
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>"

eric ide

mercurial