diff --git a/setup.py b/setup.py index ad12525766..07bf575bbc 100755 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ check_version_info() sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import setup.commands as commands -from setup import prints, get_warnings +from setup import get_warnings def option_parser(): @@ -93,13 +93,13 @@ def main(args=sys.argv): clean_backups() if opts.clean: - prints('Cleaning', args[1]) + print('Cleaning', args[1]) command.clean() return 0 if opts.clean_all: for cmd in commands.__all__: - prints('Cleaning', cmd) + print('Cleaning', cmd) getattr(commands, cmd).clean() return 0 @@ -108,10 +108,10 @@ def main(args=sys.argv): warnings = get_warnings() if warnings: print() - prints('There were', len(warnings), 'warning(s):') + print('There were', len(warnings), 'warning(s):') print() for args, kwargs in warnings: - prints('*', *args, **kwargs) + print('*', *args, **kwargs) print() return 0 diff --git a/setup/__init__.py b/setup/__init__.py index ea8c658092..b71ff1c65c 100644 --- a/setup/__init__.py +++ b/setup/__init__.py @@ -1,7 +1,6 @@ #!/usr/bin/env python2 # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai -from __future__ import with_statement -from __future__ import print_function +from __future__ import with_statement, print_function __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' @@ -120,46 +119,6 @@ initialize_constants() preferred_encoding = 'utf-8' - -def prints(*args, **kwargs): - ''' - Print unicode arguments safely by encoding them to preferred_encoding - Has the same signature as the print function from Python 3, except for the - additional keyword argument safe_encode, which if set to True will cause the - function to use repr when encoding fails. - ''' - file = kwargs.get('file', sys.stdout) - sep = kwargs.get('sep', ' ') - end = kwargs.get('end', '\n') - enc = preferred_encoding - safe_encode = kwargs.get('safe_encode', False) - for i, arg in enumerate(args): - if isinstance(arg, unicode): - try: - arg = arg.encode(enc) - except UnicodeEncodeError: - if not safe_encode: - raise - arg = repr(arg) - if not isinstance(arg, str): - try: - arg = str(arg) - except ValueError: - arg = unicode(arg) - if isinstance(arg, unicode): - try: - arg = arg.encode(enc) - except UnicodeEncodeError: - if not safe_encode: - raise - arg = repr(arg) - - file.write(arg) - if i != len(args)-1: - file.write(sep) - file.write(end) - - warnings = [] @@ -266,12 +225,12 @@ class Command(object): return newer(targets, sources) def info(self, *args, **kwargs): - prints(*args, **kwargs) + print(*args, **kwargs) sys.stdout.flush() def warn(self, *args, **kwargs): print('\n'+'_'*20, 'WARNING','_'*20) - prints(*args, **kwargs) + print(*args, **kwargs) print('_'*50) warnings.append((args, kwargs)) sys.stdout.flush()