MCPcopy
hub / github.com/tonquer/JMComic-qt / LoadCachePicture

Method LoadCachePicture

src/tools/tool.py:262–286  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

260
261 @staticmethod
262 def LoadCachePicture(filePath):
263 try:
264 c = CTime()
265 formatList = [".jpg", ".png", ".gif", ".webp", ".bmp", ".apng"]
266 for mat in formatList:
267 if filePath[-4:] in formatList:
268 path = filePath
269 elif filePath[-5:] in formatList:
270 path = filePath
271 else:
272 path = filePath + mat
273 if not os.path.isfile(path):
274 continue
275
276 with open(path, "rb") as f:
277 data = f.read()
278 c.Refresh("LoadCache", path)
279 if len(data) < 20:
280 Log.Debug(f"load_fail_picture, {path}")
281 continue
282 return data
283
284 except Exception as es:
285 Log.Error(es)
286 return None
287
288 @staticmethod
289 def SavePicture(data, path, format):

Callers 3

RunMethod · 0.80
HandlerDownloadMethod · 0.80
_DownloadMethod · 0.80

Calls 4

RefreshMethod · 0.95
CTimeClass · 0.85
DebugMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected