Close SVG files after reading. By @hroncok (#1135)

This commit is contained in:
Miro Hrončok 2021-12-11 19:51:24 +01:00 committed by GitHub
parent 17eb71a346
commit e6b247f9f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -6,7 +6,8 @@ def get_colored_icon(icon_name):
"""
Return SVG icon in the correct color.
"""
svg_str = open(get_asset(f"icons/{icon_name}.svg"), 'rb').read()
with open(get_asset(f"icons/{icon_name}.svg"), 'rb') as svg_file:
svg_str = svg_file.read()
if uses_dark_mode():
svg_str = svg_str.replace(b'#000000', b'#ffffff')
# Reduce image size to 128 height