From d4e5809a290168448c1030bb4ccf38551bb4372d Mon Sep 17 00:00:00 2001 From: Labrys Date: Sat, 4 Jun 2016 23:24:54 -0400 Subject: [PATCH] Use print_function to standardize printing between Python 2 and Python 3 --- core/__init__.py | 9 ++++++--- core/nzbToMediaDB.py | 5 +++-- core/nzbToMediaUtil.py | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 46eef2c3..6b3ca265 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1,6 +1,7 @@ # coding=utf-8 -from six.moves import reload_module +from __future__ import print_function + import locale import os import re @@ -9,6 +10,8 @@ import sys import platform import time +from six.moves import reload_module + # init libs PROGRAM_DIR = os.path.dirname(os.path.normpath(os.path.abspath(os.path.join(__file__, os.pardir)))) LIBS_DIR = os.path.join(PROGRAM_DIR, 'libs') @@ -261,8 +264,8 @@ def initialize(section=None): # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError sys.setdefaultencoding(SYS_ENCODING) except: - print 'Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable' - print 'or find another way to force Python to use ' + SYS_ENCODING + ' for string encoding.' + print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable') + print('or find another way to force Python to use ' + SYS_ENCODING + ' for string encoding.') if 'NZBOP_SCRIPTDIR' in os.environ: sys.exit(NZBGET_POSTPROCESS_ERROR) else: diff --git a/core/nzbToMediaDB.py b/core/nzbToMediaDB.py index e2ff20f6..0e1af3a9 100644 --- a/core/nzbToMediaDB.py +++ b/core/nzbToMediaDB.py @@ -1,5 +1,6 @@ # coding=utf-8 -from __future__ import with_statement + +from __future__ import print_function, with_statement import re import sqlite3 @@ -228,7 +229,7 @@ def _processUpgrade(connection, upgradeClass): try: instance.execute() except sqlite3.DatabaseError, e: - print "Error in " + str(upgradeClass.__name__) + ": " + str(e) + print("Error in " + str(upgradeClass.__name__) + ": " + str(e)) raise logger.log(upgradeClass.__name__ + " upgrade completed", logger.DEBUG) else: diff --git a/core/nzbToMediaUtil.py b/core/nzbToMediaUtil.py index 9e5eeaa5..6883b926 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -1,5 +1,7 @@ # coding=utf-8 -from __future__ import unicode_literals + +from __future__ import print_function, unicode_literals + import os import re import socket @@ -455,7 +457,7 @@ def convert_to_ascii(inputName, dirName): logger.info("Renaming directory to: %s." % (base2), 'ENCODER') os.rename(os.path.join(dir, base), dirName) if 'NZBOP_SCRIPTDIR' in os.environ: - print "[NZB] DIRECTORY=%s" % (dirName) # Return the new directory to NZBGet. + print("[NZB] DIRECTORY=%s" % (dirName)) for dirname, dirnames, filenames in os.walk(dirName, topdown=False): for subdirname in dirnames: