Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
root_path = self.path if self.path != '.' else ''
if albums_sort_attr.startswith("meta."):
meta_key = albums_sort_attr.split(".", 1)[1]
key = lambda s: locale.strxfrm(
self.gallery.albums[join(root_path, s)].meta.get(meta_key, [''])[0])
else:
key = lambda s: locale.strxfrm(
getattr(self.gallery.albums[join(root_path, s)],
albums_sort_attr))
else:
key = locale.strxfrm
self.subdirs.sort(key=key,
reverse=self.settings['albums_sort_reverse'])
signals.albums_sorted.send(self)