diff options
| author | 2022-12-04 23:25:11 -0500 | |
|---|---|---|
| committer | 2022-12-04 23:25:11 -0500 | |
| commit | b79007bb57b43b0bb5eff4aa8e5e77a782896e10 (patch) | |
| tree | 42a4b6168cc46f818465a3c25788253b2aa1b1a5 /gallery_dl/formatter.py | |
| parent | 9f3eb7898190a9f1e131a523f37e2e53cc6c6d68 (diff) | |
| parent | 3338dfce719c999467ffe08fd45663be8190057a (diff) | |
Update upstream source from tag 'upstream/1.24.1'
Update to upstream version '1.24.1'
with Debian dir 327715c78291415f1ede99ba69c817d2264b3693
Diffstat (limited to 'gallery_dl/formatter.py')
| -rw-r--r-- | gallery_dl/formatter.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gallery_dl/formatter.py b/gallery_dl/formatter.py index dd32b8a..ca05fa5 100644 --- a/gallery_dl/formatter.py +++ b/gallery_dl/formatter.py @@ -347,6 +347,20 @@ def _parse_offset(format_spec, default): return off +def _parse_sort(format_spec, default): + args, _, format_spec = format_spec.partition(_SEPARATOR) + fmt = _build_format_func(format_spec, default) + + if "d" in args or "r" in args: + def sort_desc(obj): + return fmt(sorted(obj, reverse=True)) + return sort_desc + else: + def sort_asc(obj): + return fmt(sorted(obj)) + return sort_asc + + def _default_format(format_spec, default): def wrap(obj): return format(obj, format_spec) @@ -395,4 +409,5 @@ _FORMAT_SPECIFIERS = { "J": _parse_join, "O": _parse_offset, "R": _parse_replace, + "S": _parse_sort, } |
