Use six.iteritems helper

* Standardizes dict.iteritems between Python 2 and Python 3
This commit is contained in:
Labrys 2016-06-05 08:58:17 -04:00
parent d4e5809a29
commit abf63d6bbe
3 changed files with 11 additions and 5 deletions

View file

@ -2,6 +2,8 @@
import requests import requests
from six import iteritems
import core import core
from core import logger from core import logger
@ -89,7 +91,7 @@ def autoFork(section, inputCategory):
rem_params.append(param) rem_params.append(param)
for param in rem_params: for param in rem_params:
params.pop(param) params.pop(param)
for fork in sorted(core.FORKS.iteritems(), reverse=False): for fork in sorted(iteritems(core.FORKS), reverse=False):
if params == fork[1]: if params == fork[1]:
detected = True detected = True
break break

View file

@ -1,4 +1,6 @@
# coding=utf-8 # coding=utf-8
from six import iteritems
import os import os
import shutil import shutil
import copy import copy
@ -150,7 +152,7 @@ class ConfigObj(configobj.ConfigObj, Section):
continue continue
def cleanup_values(values, section): def cleanup_values(values, section):
for option, value in values.iteritems(): for option, value in iteritems(values):
if section in ['CouchPotato']: if section in ['CouchPotato']:
if option == ['outputDirectory']: if option == ['outputDirectory']:
CFG_NEW['Torrent'][option] = os.path.split(os.path.normpath(value))[0] CFG_NEW['Torrent'][option] = os.path.split(os.path.normpath(value))[0]
@ -227,7 +229,7 @@ class ConfigObj(configobj.ConfigObj, Section):
subsection = None subsection = None
if section in list(chain.from_iterable(subsections.values())): if section in list(chain.from_iterable(subsections.values())):
subsection = section subsection = section
section = ''.join([k for k, v in subsections.iteritems() if subsection in v]) section = ''.join([k for k, v in iteritems(subsections) if subsection in v])
process_section(section, subsection) process_section(section, subsection)
elif section in subsections.keys(): elif section in subsections.keys():
subsection = subsections[section] subsection = subsections[section]

View file

@ -1,4 +1,6 @@
# coding=utf-8 # coding=utf-8
from six import iteritems
import errno import errno
import os import os
import platform import platform
@ -128,7 +130,7 @@ def buildCommands(file, newDir, movieName, bitbucket):
if ext == core.VEXTENSION and newDir == dir: # we need to change the name to prevent overwriting itself. if ext == core.VEXTENSION and newDir == dir: # we need to change the name to prevent overwriting itself.
core.VEXTENSION = '-transcoded' + core.VEXTENSION # adds '-transcoded.ext' core.VEXTENSION = '-transcoded' + core.VEXTENSION # adds '-transcoded.ext'
else: else:
img, data = file.iteritems().next() img, data = iteritems(file).next()
name = data['name'] name = data['name']
video_details, result = getVideoDetails(data['files'][0], img, bitbucket) video_details, result = getVideoDetails(data['files'][0], img, bitbucket)
inputFile = '-' inputFile = '-'
@ -774,7 +776,7 @@ def Transcode_directory(dirName):
if isinstance(file, str): if isinstance(file, str):
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket)
else: else:
img, data = file.iteritems().next() img, data = iteritems(file).next()
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket, stdin=subprocess.PIPE) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket, stdin=subprocess.PIPE)
for vob in data['files']: for vob in data['files']:
procin = zip_out(vob, img, bitbucket) procin = zip_out(vob, img, bitbucket)