eric6/Templates/TemplatesFile.py

changeset 8240
93b8a353c4bf
parent 8218
7c09585bd960
equal deleted inserted replaced
8239:59a9a658618c 8240:93b8a353c4bf
74 74
75 try: 75 try:
76 jsonString = json.dumps(templatesDict, indent=2) 76 jsonString = json.dumps(templatesDict, indent=2)
77 with open(filename, "w") as f: 77 with open(filename, "w") as f:
78 f.write(jsonString) 78 f.write(jsonString)
79 except (TypeError, EnvironmentError) as err: 79 except (TypeError, OSError) as err:
80 with E5OverridenCursor(): 80 with E5OverridenCursor():
81 E5MessageBox.critical( 81 E5MessageBox.critical(
82 None, 82 None,
83 self.tr("Save Templates"), 83 self.tr("Save Templates"),
84 self.tr( 84 self.tr(
101 """ 101 """
102 try: 102 try:
103 with open(filename, "r") as f: 103 with open(filename, "r") as f:
104 jsonString = f.read() 104 jsonString = f.read()
105 templatesDict = json.loads(jsonString) 105 templatesDict = json.loads(jsonString)
106 except (EnvironmentError, json.JSONDecodeError) as err: 106 except (OSError, json.JSONDecodeError) as err:
107 E5MessageBox.critical( 107 E5MessageBox.critical(
108 None, 108 None,
109 self.tr("Read Templates"), 109 self.tr("Read Templates"),
110 self.tr( 110 self.tr(
111 "<p>The templates file <b>{0}</b> could not be read.</p>" 111 "<p>The templates file <b>{0}</b> could not be read.</p>"

eric ide

mercurial