eric6/WebBrowser/Tools/WebIconProvider.py

changeset 7785
9978016560ec
parent 7781
607a6098cb44
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
86 86
87 if self.__iconDatabasePath: 87 if self.__iconDatabasePath:
88 filename = os.path.join(self.__iconDatabasePath, 88 filename = os.path.join(self.__iconDatabasePath,
89 self.__iconsFileName) 89 self.__iconsFileName)
90 try: 90 try:
91 f = open(filename, "r") 91 with open(filename, "r") as f:
92 db = json.load(f) 92 db = json.load(f)
93 f.close()
94 except (IOError, OSError): 93 except (IOError, OSError):
95 # ignore silentyl 94 # ignore silentyl
96 db = {} 95 db = {}
97 96
98 self.__iconsDB = {} 97 self.__iconsDB = {}
120 db[url] = bytes(buffer.data()).decode(self.__encoding) 119 db[url] = bytes(buffer.data()).decode(self.__encoding)
121 120
122 filename = os.path.join(self.__iconDatabasePath, 121 filename = os.path.join(self.__iconDatabasePath,
123 self.__iconsFileName) 122 self.__iconsFileName)
124 try: 123 try:
125 f = open(filename, "w") 124 with open(filename, "w") as f:
126 json.dump(db, f) 125 json.dump(db, f)
127 f.close()
128 except (IOError, OSError): 126 except (IOError, OSError):
129 # ignore silentyl 127 # ignore silentyl
130 pass 128 pass
131 129
132 def saveIcon(self, view): 130 def saveIcon(self, view):

eric ide

mercurial