Skip to content

Commit dec042a

Browse files
committed
Change function signatures and reflow docstrings in base64.py
Improve consistency in parameter names and formatting.
1 parent 2d280e9 commit dec042a

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

Lib/base64.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -293,61 +293,61 @@ def b16decode(s, casefold=False):
293293
#
294294
# Ascii85 encoding/decoding
295295
#
296-
def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
297-
"""Encode bytes-like object b using Ascii85 and return a bytes object.
296+
def a85encode(s, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
297+
"""Encode the bytes-like object s using Ascii85 and return a bytes object.
298298
299299
foldspaces is an optional flag that uses the special short sequence 'y'
300300
instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This
301301
feature is not supported by the "standard" Adobe encoding.
302302
303-
wrapcol controls whether the output should have newline (b'\\n') characters
304-
added to it. If this is non-zero, each output line will be at most this
305-
many characters long.
303+
wrapcol controls whether the output should have newline (b'\\n')
304+
characters added to it. If this is non-zero, each output line will be at
305+
most this many characters long.
306306
307307
pad controls whether the input is padded to a multiple of 4 before
308308
encoding. Note that the btoa implementation always pads.
309309
310310
adobe controls whether the encoded byte sequence is framed with <~ and ~>,
311311
which is used by the Adobe implementation.
312312
"""
313-
return binascii.b2a_ascii85(b, fold_spaces=foldspaces,
313+
return binascii.b2a_ascii85(s, fold_spaces=foldspaces,
314314
wrap=adobe, width=wrapcol, pad=pad)
315315

316-
def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'):
317-
"""Decode the Ascii85 encoded bytes-like object or ASCII string b.
316+
def a85decode(s, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'):
317+
"""Decode the Ascii85 encoded bytes-like object or ASCII string s.
318318
319-
foldspaces is a flag that specifies whether the 'y' short sequence should be
320-
accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This feature is
321-
not supported by the "standard" Adobe encoding.
319+
foldspaces is a flag that specifies whether the 'y' short sequence
320+
should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
321+
This feature is not supported by the "standard" Adobe encoding.
322322
323-
adobe controls whether the input sequence is in Adobe Ascii85 format (i.e.
324-
is framed with <~ and ~>).
323+
adobe controls whether the input sequence is in Adobe Ascii85 format
324+
(i.e. is framed with <~ and ~>).
325325
326-
ignorechars should be a byte string containing characters to ignore from the
327-
input. This should only contain whitespace characters, and by default
326+
ignorechars should be a byte string containing characters to ignore from
327+
the input. This should only contain whitespace characters, and by default
328328
contains all whitespace characters in ASCII.
329329
330330
The result is returned as a bytes object.
331331
"""
332-
b = _bytes_from_decode_data(b)
333-
return binascii.a2b_ascii85(b, fold_spaces=foldspaces,
332+
s = _bytes_from_decode_data(s)
333+
return binascii.a2b_ascii85(s, fold_spaces=foldspaces,
334334
wrap=adobe, ignore=ignorechars)
335335

336-
def b85encode(b, pad=False):
337-
"""Encode bytes-like object b in base85 format and return a bytes object.
336+
def b85encode(s, pad=False):
337+
"""Encode the bytes-like object s using base85 and return a bytes object.
338338
339-
If pad is true, the input is padded with b'\\0' so its length is a multiple of
340-
4 bytes before encoding.
339+
If pad is True, the input is padded with b'\\0' so its length is a
340+
multiple of 4 bytes before encoding.
341341
"""
342-
return binascii.b2a_base85(b, pad=pad, newline=False)
342+
return binascii.b2a_base85(s, pad=pad, newline=False)
343343

344-
def b85decode(b):
345-
"""Decode the base85-encoded bytes-like object or ASCII string b
344+
def b85decode(s):
345+
"""Decode the base85-encoded bytes-like object or ASCII string s.
346346
347347
The result is returned as a bytes object.
348348
"""
349-
b = _bytes_from_decode_data(b)
350-
return binascii.a2b_base85(b, strict_mode=True)
349+
s = _bytes_from_decode_data(s)
350+
return binascii.a2b_base85(s, strict_mode=True)
351351

352352
_b85alphabet = (b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
353353
b"abcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~")
@@ -363,11 +363,11 @@ def b85decode(b):
363363
_z85_encode_translation = bytes.maketrans(_b85alphabet, _z85alphabet)
364364

365365
def z85encode(s):
366-
"""Encode bytes-like object b in z85 format and return a bytes object."""
366+
"""Encode the bytes-like object s using z85 and return a bytes object."""
367367
return b85encode(s).translate(_z85_encode_translation)
368368

369369
def z85decode(s):
370-
"""Decode the z85-encoded bytes-like object or ASCII string b
370+
"""Decode the z85-encoded bytes-like object or ASCII string s.
371371
372372
The result is returned as a bytes object.
373373
"""

0 commit comments

Comments
 (0)