mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
use context managers to open files for reading
This commit is contained in:
parent
e4ea6f9e15
commit
7358e09e88
@ -20,7 +20,8 @@ def available_translations():
|
||||
stats = P('localization/stats.calibre_msgpack', allow_user_override=False)
|
||||
if os.path.exists(stats):
|
||||
from calibre.utils.serialize import msgpack_loads
|
||||
stats = msgpack_loads(open(stats, 'rb').read())
|
||||
with open(stats, 'rb') as f:
|
||||
stats = msgpack_loads(f.read())
|
||||
else:
|
||||
stats = {}
|
||||
_available_translations = [x for x in stats if stats[x] > 0.1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user