From f39d577421bc2e4b041b5d22e788f4615ef78d77 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 8 Feb 2023 21:16:55 +0100 Subject: adapt to upstream changes --- tagit/widgets/browser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tagit/widgets') diff --git a/tagit/widgets/browser.py b/tagit/widgets/browser.py index 4a254ee..1e42c9c 100644 --- a/tagit/widgets/browser.py +++ b/tagit/widgets/browser.py @@ -7,6 +7,7 @@ Author: Matthias Baumgartner, 2022 # standard imports from collections import defaultdict from functools import reduce, partial +import io import logging import math import operator @@ -421,8 +422,13 @@ class Browser(GridLayout, StorageAwareMixin, ConfigAwareMixin): # select the best fitting preview chosen = rmatcher.by_area_min(resolution, options) # open the preview file, default if no asset is available - thumb = open(chosen.get(ns.bsp.asset, default=default), 'rb') # FIXME: mb/port: asset storage - except IndexError: + thumb_data = chosen.asset(default=None) # FIXME: get all assets in one call + if thumb_data is None: + raise KeyError() + thumb = io.BytesIO(thumb_data) + + except (KeyError, IndexError): + # KeyError: # no viable resolution found thumb = open(default, 'rb') # update the image in the child widget -- cgit v1.2.3