From 4ae7448c25dfd888ff5c5b810772b0866eace6fb Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 29 Jun 2016 10:12:38 -0700 Subject: [PATCH] Simplify print_ changes (#2094) --- beets/ui/__init__.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 4fd79974f..21966b2c6 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -135,7 +135,8 @@ def print_(*strings, **kwargs): is not in the terminal's encoding's character set, just silently replaces it. - The arguments must be unicode strings + The arguments must be Unicode strings: `unicode` on Python 2; `str` on + Python 3. The `end` keyword argument behaves similarly to the built-in `print` (it defaults to a newline). The value should have the same string @@ -143,17 +144,14 @@ def print_(*strings, **kwargs): """ if not strings: strings = [u''] - - end = kwargs.get('end') assert isinstance(strings[0], six.text_type) txt = u' '.join(strings) - txt += u'\n' if end is None else end + txt += kwargs.get('end', u'\n') - # Always send bytes to the stdout stream on python 2. + # Send bytes to the stdout stream on Python 2. if six.PY2: - if isinstance(txt, six.text_type): - txt = txt.encode(_out_encoding(), 'replace') + txt = txt.encode(_out_encoding(), 'replace') sys.stdout.write(txt)