Skip to content

Commit

Permalink
Use str.join().
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Mar 20, 2024
1 parent 015715d commit 8e63692
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_slice_repr(lst):
def fold(lst, obj):
return lst + [obj - sum(lst)]
plus_lst = functools.reduce(fold, lst[1:], lst[:1])
return '+'.join(map(str, plus_lst))
return str.join('+', map(str, plus_lst))

class intact(object):

Expand Down Expand Up @@ -344,11 +344,11 @@ def dump_options(o, multipage=False):
method_name = o.method.name
if o.params:
method_name += ' '
method_name += ' '.join(
method_name += str.join(' ', (
'{0}={1}'.format(pname, pvalue)
for pname, pvalue
in sorted(o.params.iteritems())
)
))
yield ('method', method_name)
if multipage:
yield ('pages-per-dict', o.pages_per_dict)
Expand Down
2 changes: 1 addition & 1 deletion lib/djvu_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def photo_to_djvu(image, dpi=100, slices=IW44_SLICES_DEFAULT, gamma=2.2, mask_im
args = [
'c44',
'-dpi', str(dpi),
'-slice', ','.join(map(str, slices)),
'-slice', str.join(',', map(str, slices)),
'-gamma', '{0:.1f}'.format(gamma),
'-crcb{0}'.format(crcb),
]
Expand Down
2 changes: 1 addition & 1 deletion lib/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __str__(self):
# ==========

def shell_escape(commandline):
return ' '.join(map(pipes.quote, commandline))
return str.join(' ', map(pipes.quote, commandline))

class Subprocess(subprocess.Popen):

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_no_args(self):
assert_multi_line_equal(
stderr.getvalue(),
'usage: didjvu [-h] [--version] {{{actions}}} ...\n'
'didjvu: error: too few arguments\n'.format(actions=','.join(self.anames))
'didjvu: error: too few arguments\n'.format(actions=str.join(',', self.anames))
)

def _test_action_no_args(self, action):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _test_locale(self):
if utf8_locale is None:
raise SkipTest(
'UTF-8 locale missing '
'({0})'.format(' or '.join(utf8_locale_candidates))
'({0})'.format(str.join(' or ', utf8_locale_candidates))
)
assert_equal(value, utf8_locale)
elif key == 'LANG':
Expand Down
2 changes: 1 addition & 1 deletion tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def wrapper(*args, **kwargs):
except Exception:
exctp, exc, tb = sys.exc_info()
s = traceback.format_exception(exctp, exc, tb, _n_relevant_tb_levels(tb))
s = ''.join(s)
s = str.join('', s)
del tb
with os.fdopen(writefd, 'wb') as fp:
fp.write(s)
Expand Down

0 comments on commit 8e63692

Please sign in to comment.