From 7ffd36388b04c4c9d4f0176167201ed7b8e30e9c Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 13 Jun 2015 22:52:46 +0800 Subject: [PATCH] Change py2 iteritems to py2/3 compatible statements using six library --- CHANGES.md | 1 + sickbeard/clients/utorrent.py | 3 ++- sickbeard/metadata/generic.py | 5 +++-- sickbeard/metadata/mediabrowser.py | 3 ++- sickbeard/network_timezones.py | 3 ++- sickbeard/webserve.py | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1db8c413..45ff01cf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,6 +35,7 @@ * Change py2 exception clauses to py2/3 compatible clauses * Change py2 print statements to py2/3 compatible functions * Change py2 octal literals into the new py2/3 syntax +* Change py2 iteritems to py2/3 compatible statements using six library * Change Kodi notifier to use requests as opposed to urllib * Change to consolidate scene exceptions and name cache code * Change check_url function to use requests instead of httplib library diff --git a/sickbeard/clients/utorrent.py b/sickbeard/clients/utorrent.py index 73781768..02fd82bd 100644 --- a/sickbeard/clients/utorrent.py +++ b/sickbeard/clients/utorrent.py @@ -21,6 +21,7 @@ import re import sickbeard from sickbeard import logger from sickbeard.clients.generic import GenericClient +from six import iteritems import urllib @@ -36,7 +37,7 @@ class uTorrentAPI(GenericClient): return super(uTorrentAPI, self)._request( method=method, params='token={0:s}&{1:s}'.format(self.auth, '&'.join( - ['%s' % urllib.urlencode(dict([[key, str(value)]])) for key, value in params.iteritems()])) if any(params) else params, + ['%s' % urllib.urlencode(dict([[key, str(value)]])) for key, value in iteritems(params)])) if any(params) else params, files=files) def _get_auth(self): diff --git a/sickbeard/metadata/generic.py b/sickbeard/metadata/generic.py index d4457432..02436c5c 100644 --- a/sickbeard/metadata/generic.py +++ b/sickbeard/metadata/generic.py @@ -32,6 +32,7 @@ from sickbeard import logger from sickbeard import encodingKludge as ek from sickbeard.exceptions import ex from sickbeard.show_name_helpers import allPossibleShowNames +from six import iteritems from lib.tmdb_api.tmdb_api import TMDB @@ -338,7 +339,7 @@ class GenericMetadata(): def create_season_posters(self, show_obj): if self.season_posters and show_obj: result = [] - for season, episodes in show_obj.episodes.iteritems(): # @UnusedVariable + for season, episodes in iteritems(show_obj.episodes): # @UnusedVariable if not self._has_season_poster(show_obj, season): logger.log(u"Metadata provider " + self.name + " creating season posters for " + show_obj.name, logger.DEBUG) @@ -349,7 +350,7 @@ class GenericMetadata(): def create_season_banners(self, show_obj): if self.season_banners and show_obj: result = [] - for season, episodes in show_obj.episodes.iteritems(): # @UnusedVariable + for season, episodes in iteritems(show_obj.episodes): # @UnusedVariable if not self._has_season_banner(show_obj, season): logger.log(u"Metadata provider " + self.name + " creating season banners for " + show_obj.name, logger.DEBUG) diff --git a/sickbeard/metadata/mediabrowser.py b/sickbeard/metadata/mediabrowser.py index e57a53bd..9e43db6a 100644 --- a/sickbeard/metadata/mediabrowser.py +++ b/sickbeard/metadata/mediabrowser.py @@ -30,6 +30,7 @@ from sickbeard import encodingKludge as ek from sickbeard.exceptions import ex import xml.etree.cElementTree as etree +from six import iteritems class MediaBrowserMetadata(generic.GenericMetadata): @@ -536,7 +537,7 @@ class MediaBrowserMetadata(generic.GenericMetadata): persons_dict['Writer'] += [x.strip() for x in myEp['writer'].split('|') if x] # fill in Persons section with collected directors, guest starts and writers - for person_type, names in persons_dict.iteritems(): + for person_type, names in iteritems(persons_dict): # remove doubles names = list(set(names)) for cur_name in names: diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index acc31a8f..d4563c8d 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -26,6 +26,7 @@ from os.path import basename, join, isfile import os import re import datetime +from six import iteritems # regex to parse time (12/24 hour format) time_regex = re.compile(r'(\d{1,2})(([:.](\d{2,2}))? ?([PA][. ]? ?M)|[:.](\d{2,2}))\b', flags=re.IGNORECASE) @@ -170,7 +171,7 @@ def update_network_dict(): # list of sql commands to update the network_timezones table cl = [] - for cur_d, cur_t in d.iteritems(): + for cur_d, cur_t in iteritems(d): h_k = old_d.has_key(cur_d) if h_k and cur_t != old_d[cur_d]: # update old record diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index b1094446..61661f2f 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -28,6 +28,7 @@ import traceback from mimetypes import MimeTypes from Cheetah.Template import Template +from six import iteritems import sickbeard from sickbeard import config, sab, clients, history, notifiers, processTV, ui, logger, helpers, exceptions, classes, \ @@ -1219,7 +1220,7 @@ class Home(MainHandler): return 'No scene exceptions' out = [] - for season, names in iter(sorted(exceptionsList.iteritems())): + for season, names in iter(sorted(iteritems(exceptionsList))): if season == -1: season = '*' out.append('S' + str(season) + ': ' + ', '.join(names))