"""Browser for image files."""
from json import dump as json_dump, load as json_load
from functools import cmp_to_key
+from re import search as re_search
from os import listdir
from os.path import (exists as path_exists, join as path_join, abspath, isdir,
splitext, getmtime)
def _ensure_updated_view(self):
"""Rather than reload slots every scroll pixel, regularly run this."""
- if self._should_update_view:
+ if self._should_update_view and self.slots:
self._update_view(refocus=False, force=True)
return True
def _filter_func(self, item):
"""Return if item matches user-set filters."""
+ number_attributes = set(GEN_PARAMS_INT) | set(GEN_PARAMS_FLOAT) | {
+ 'BOOKMARKED'}
def number_filter(attr_name, filter_line, to_compare):
use_float = attr_name.upper() in GEN_PARAMS_FLOAT
if not hasattr(item, filter_attribute):
return False
to_compare = getattr(item, filter_attribute)
- number_attributes = set(GEN_PARAMS_INT) | set(GEN_PARAMS_FLOAT) | {
- 'BOOKMARKED'}
if filter_attribute.upper() in number_attributes:
if not number_filter(filter_attribute, value, to_compare):
return False
- elif value not in to_compare:
+ elif not re_search(value, to_compare):
return False
return True
to_set_metadata_on += [item]
self.gallery.dir_entries += [item]
print('')
- if len(to_set_metadata_on):
+ if to_set_metadata_on:
for i, item in enumerate(to_set_metadata_on):
msg = f'setting metadata: {i+1}/{len(to_set_metadata_on)}'
print(msg, end='\r')