diff --git a/core/main_db.py b/core/main_db.py index 7917cdd9..b1331ac8 100644 --- a/core/main_db.py +++ b/core/main_db.py @@ -2,8 +2,6 @@ import re import sqlite3 import time -from six import text_type - import core from core import logger @@ -188,7 +186,7 @@ class DBConnection: 'INSERT OR IGNORE INTO {table} ({columns}) ' 'VALUES ({values})'.format( table=table_name, - columns=', '.join(map(text_type, value_dict.keys())), + columns=', '.join(map(str, value_dict.keys())), values=', '.join(['?'] * len(value_dict.values())), ), list(value_dict.values()), diff --git a/core/processor/manual.py b/core/processor/manual.py index 4227cf3c..5a4b106f 100644 --- a/core/processor/manual.py +++ b/core/processor/manual.py @@ -9,11 +9,6 @@ from core.utils import ( get_download_info, ) -try: - text_type = unicode -except NameError: - text_type = str - def process(): # Perform Manual Post-Processing @@ -44,10 +39,8 @@ def process(): logger.info('Found download info for {0}, ' 'setting variables now ...'.format (os.path.basename(dir_name))) - client_agent = text_type( - core.DOWNLOAD_INFO[0]['client_agent']) or 'manual' - download_id = text_type( - core.DOWNLOAD_INFO[0]['input_id']) or '' + client_agent = core.DOWNLOAD_INFO[0]['client_agent'] or 'manual' + download_id = core.DOWNLOAD_INFO[0]['input_id'] or '' else: logger.info('Unable to locate download info for {0}, ' 'continuing to try and process this release ...'.format diff --git a/core/processor/nzb.py b/core/processor/nzb.py index a649654e..4cbf5161 100644 --- a/core/processor/nzb.py +++ b/core/processor/nzb.py @@ -15,11 +15,6 @@ from core.utils import ( update_download_info_status, ) -try: - text_type = unicode -except NameError: - text_type = str - def process(input_directory, input_name=None, status=0, client_agent='manual', download_id=None, input_category=None, failure_link=None): if core.SAFE_MODE and input_directory == core.NZB_DEFAULT_DIRECTORY: @@ -48,12 +43,12 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d except Exception: pass - control_value_dict = {'input_directory': text_type(input_directory1)} + control_value_dict = {'input_directory': input_directory1} new_value_dict = { - 'input_name': text_type(input_name1), - 'input_hash': text_type(download_id), - 'input_id': text_type(download_id), - 'client_agent': text_type(client_agent), + 'input_name': input_name1, + 'input_hash': download_id, + 'input_id': download_id, + 'client_agent': client_agent, 'status': 0, 'last_update': datetime.date.today().toordinal(), } diff --git a/core/transcoder.py b/core/transcoder.py index 69b3821f..cd2cae02 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -9,7 +9,7 @@ import shutil import subprocess from babelfish import Language -from six import iteritems, string_types, text_type +from six import iteritems, string_types import core from core import logger @@ -511,7 +511,6 @@ def build_commands(file, new_dir, movie_name, bitbucket): continue command.extend(['-i', subfile]) lan = os.path.splitext(os.path.splitext(subfile)[0])[1][1:].split('-')[0] - lan = text_type(lan) metlan = None try: if len(lan) == 3: @@ -981,7 +980,7 @@ def transcode_directory(dir_name): os.unlink(file) except Exception: pass - if not os.listdir(text_type(new_dir)): # this is an empty directory and we didn't transcode into it. + if not os.listdir(new_dir): # this is an empty directory and we didn't transcode into it. os.rmdir(new_dir) new_dir = dir_name if not core.PROCESSOUTPUT and core.DUPLICATE: # We postprocess the original files to CP/SB diff --git a/core/utils/common.py b/core/utils/common.py index 9b21936c..6583830d 100644 --- a/core/utils/common.py +++ b/core/utils/common.py @@ -1,7 +1,5 @@ import os.path -from six import text_type - import core from core import logger from core.utils.files import list_media_files, move_file @@ -27,7 +25,7 @@ def process_dir(path, link): folders = [] logger.info('Searching {0} for mediafiles to post-process ...'.format(path)) - dir_contents = os.listdir(text_type(path)) + dir_contents = os.listdir(path) # search for single files and move them into their own folder for post-processing @@ -63,7 +61,7 @@ def process_dir(path, link): # Generate all path contents path_contents = ( os.path.join(path, item) - for item in os.listdir(text_type(path)) + for item in os.listdir(path) ) # Generate all directories from path contents diff --git a/core/utils/download_info.py b/core/utils/download_info.py index ce6e6717..063ab2bd 100644 --- a/core/utils/download_info.py +++ b/core/utils/download_info.py @@ -1,7 +1,5 @@ import datetime -from six import text_type - from core import logger, main_db database = main_db.DBConnection() @@ -10,7 +8,7 @@ database = main_db.DBConnection() def update_download_info_status(input_name, status): msg = 'Updating DB download status of {0} to {1}' action = 'UPDATE downloads SET status=?, last_update=? WHERE input_name=?' - args = [status, datetime.date.today().toordinal(), text_type(input_name)] + args = [status, datetime.date.today().toordinal(), input_name] logger.db(msg.format(input_name, status)) database.action(action, args) @@ -18,6 +16,6 @@ def update_download_info_status(input_name, status): def get_download_info(input_name, status): msg = 'Getting download info for {0} from the DB' action = 'SELECT * FROM downloads WHERE input_name=? AND status=?' - args = [text_type(input_name), status] + args = [input_name, status] logger.db(msg.format(input_name)) return database.select(action, args) diff --git a/core/utils/encoding.py b/core/utils/encoding.py index 4e89321d..a5b21fa1 100644 --- a/core/utils/encoding.py +++ b/core/utils/encoding.py @@ -1,8 +1,6 @@ import os from builtins import bytes -from six import text_type - import core from core import logger @@ -16,7 +14,7 @@ def char_replace(name_in): # If there is special character, detects if it is a UTF-8, CP850 or ISO-8859-15 encoding encoded = False encoding = None - if isinstance(name_in, text_type): + if isinstance(name_in, str): return encoded, name_in name = bytes(name_in) for Idx in range(len(name)): diff --git a/core/utils/files.py b/core/utils/files.py index 57144304..b893ff23 100644 --- a/core/utils/files.py +++ b/core/utils/files.py @@ -6,7 +6,6 @@ import time import beets.mediafile import guessit -from six import text_type import core from core import extractor, logger @@ -141,7 +140,7 @@ def list_media_files(path, min_size=0, delete_ignored=0, media=True, audio=True, return files - for cur_file in os.listdir(text_type(path)): + for cur_file in os.listdir(path): full_cur_file = os.path.join(path, cur_file) # if it's a folder do it recursively diff --git a/core/utils/identification.py b/core/utils/identification.py index 2dc00250..f1ddeeb1 100644 --- a/core/utils/identification.py +++ b/core/utils/identification.py @@ -3,7 +3,6 @@ import re import guessit import requests -from six import text_type from core import logger from core.utils.naming import sanitize_name @@ -22,7 +21,7 @@ def find_imdbid(dir_name, input_name, omdb_api_key): logger.info('Found imdbID [{0}]'.format(imdbid)) return imdbid if os.path.isdir(dir_name): - for file in os.listdir(text_type(dir_name)): + for file in os.listdir(dir_name): m = re.search(r'\b(tt\d{7,8})\b', file) if m: imdbid = m.group(1) @@ -138,7 +137,7 @@ def category_search(input_directory, input_name, input_category, root, categorie logger.info('SEARCH: Setting input_directory to {0}'.format(input_directory)) tordir = True elif input_name and os.path.isdir(input_directory): - for file in os.listdir(text_type(input_directory)): + for file in os.listdir(input_directory): if os.path.splitext(file)[0] in [input_name, sanitize_name(input_name)]: logger.info('SEARCH: Found torrent file {0} in input directory directory {1}'.format(file, input_directory)) input_directory = os.path.join(input_directory, file) diff --git a/core/utils/paths.py b/core/utils/paths.py index 0afc3035..c7fab07f 100644 --- a/core/utils/paths.py +++ b/core/utils/paths.py @@ -4,8 +4,6 @@ import re import shutil import stat -from six import text_type - import core from core import logger @@ -32,7 +30,7 @@ def onerror(func, path, exc_info): def remove_dir(dir_name): logger.info('Deleting {0}'.format(dir_name)) try: - shutil.rmtree(text_type(dir_name), onerror=onerror) + shutil.rmtree(dir_name, onerror=onerror) except Exception: logger.error('Unable to delete folder {0}'.format(dir_name)) @@ -68,7 +66,7 @@ def get_dir_size(input_path): prepend = partial(os.path.join, input_path) return sum( (os.path.getsize(f) if os.path.isfile(f) else get_dir_size(f)) - for f in map(prepend, os.listdir(text_type(input_path))) + for f in map(prepend, os.listdir(input_path)) ) @@ -79,7 +77,7 @@ def remove_empty_folders(path, remove_root=True): # remove empty subfolders logger.debug('Checking for empty folders in:{0}'.format(path)) - files = os.listdir(text_type(path)) + files = os.listdir(path) if len(files): for f in files: fullpath = os.path.join(path, f) @@ -87,7 +85,7 @@ def remove_empty_folders(path, remove_root=True): remove_empty_folders(fullpath) # if folder empty, delete it - files = os.listdir(text_type(path)) + files = os.listdir(path) if len(files) == 0 and remove_root: logger.debug('Removing empty folder:{}'.format(path)) os.rmdir(path)