Skip to content

Commit

Permalink
[formatter] do NOT apply :J to strings (#2833)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 16, 2022
1 parent 590f2e2 commit 6990ad0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions gallery_dl/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,14 @@ def mlen(obj):

def _parse_join(format_spec, default):
separator, _, format_spec = format_spec.partition(_SEPARATOR)
separator = separator[1:]
join = separator[1:].join
fmt = _build_format_func(format_spec, default)

def join(obj):
return fmt(separator.join(obj))
return join
def apply_join(obj):
if isinstance(obj, str):
return fmt(obj)
return fmt(join(obj))
return apply_join


def _parse_replace(format_spec, default):
Expand Down
2 changes: 1 addition & 1 deletion test/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_join(self):
self._run_test("{l:J - />20}", " a - b - c")

self._run_test("{a:J/}" , self.kwdict["a"])
self._run_test("{a:J, /}" , ", ".join(self.kwdict["a"]))
self._run_test("{a:J, /}" , self.kwdict["a"])

def test_replace(self):
self._run_test("{a:Rh/C/}" , "CElLo wOrLd")
Expand Down

0 comments on commit 6990ad0

Please sign in to comment.