#!/usr/bin/env python3
from json import dump as json_dump, load as json_load
from os.path import exists as path_exists, join as path_join, abspath
-from random import shuffle
from operator import attrgetter
from exiftool import ExifToolHelper # type: ignore
import gi # type: ignore
IMG_DIR = '.'
CACHE_PATH = 'cache.json'
-SORT_KEY_RANDOM = 'randomize'
class SortLabelItem(GObject.GObject):
def sort(self):
self.list_store.remove_all()
for key in self.sort_order:
- if SORT_KEY_RANDOM == key:
- shuffle(self.unsorted_files)
- shuffle(self.unsorted_dirs)
- continue
self.unsorted_files.sort(key=attrgetter(key))
if key in {'name', 'last_mod_time'}:
self.unsorted_dirs.sort(key=attrgetter(key))