py3k port helpers
This commit is contained in:
@@ -169,7 +169,7 @@ class Plugin(object):
|
||||
}
|
||||
method = 'post' if len(data) > 0 or files else 'get'
|
||||
|
||||
log.info('Opening url: %s %s, data: %s', (method, url, [x for x in data.iterkeys()] if isinstance(data, dict) else 'with data'))
|
||||
log.info('Opening url: %s %s, data: %s', (method, url, [x for x in data.keys()] if isinstance(data, dict) else 'with data'))
|
||||
response = r.request(method, url, verify = False, **kwargs)
|
||||
|
||||
data = response.content
|
||||
|
||||
@@ -4,6 +4,7 @@ from couchpotato.core.plugins.base import Plugin
|
||||
import ctypes
|
||||
import os
|
||||
import string
|
||||
import six
|
||||
|
||||
if os.name == 'nt':
|
||||
import imp
|
||||
@@ -96,7 +97,7 @@ class FileBrowser(Plugin):
|
||||
|
||||
def has_hidden_attribute(self, filepath):
|
||||
try:
|
||||
attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath)) #@UndefinedVariable
|
||||
attrs = ctypes.windll.kernel32.GetFileAttributesW(six.text_type(filepath)) #@UndefinedVariable
|
||||
assert attrs != -1
|
||||
result = bool(attrs & 2)
|
||||
except (AttributeError, AssertionError):
|
||||
|
||||
@@ -223,7 +223,7 @@ class Manage(Plugin):
|
||||
groups = fireEvent('scanner.scan', folder = folder, files = files, single = True)
|
||||
|
||||
if groups:
|
||||
for group in groups.itervalues():
|
||||
for group in groups.values():
|
||||
if group['library'] and group['library'].get('identifier'):
|
||||
fireEvent('release.add', group = group)
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import re
|
||||
import shutil
|
||||
import time
|
||||
import traceback
|
||||
import six
|
||||
from six.moves import filter
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -787,19 +789,19 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
||||
replacements['cd_nr'] = ''
|
||||
|
||||
replaced = toUnicode(string)
|
||||
for x, r in replacements.iteritems():
|
||||
for x, r in replacements.items():
|
||||
if x in ['thename', 'namethe']:
|
||||
continue
|
||||
if r is not None:
|
||||
replaced = replaced.replace(u'<%s>' % toUnicode(x), toUnicode(r))
|
||||
replaced = replaced.replace(six.u('<%s>') % toUnicode(x), toUnicode(r))
|
||||
else:
|
||||
#If information is not available, we don't want the tag in the filename
|
||||
replaced = replaced.replace('<' + x + '>', '')
|
||||
|
||||
replaced = self.replaceDoubles(replaced.lstrip('. '))
|
||||
for x, r in replacements.iteritems():
|
||||
for x, r in replacements.items():
|
||||
if x in ['thename', 'namethe']:
|
||||
replaced = replaced.replace(u'<%s>' % toUnicode(x), toUnicode(r))
|
||||
replaced = replaced.replace(six.u('<%s>') % toUnicode(x), toUnicode(r))
|
||||
replaced = re.sub(r"[\x00:\*\?\"<>\|]", '', replaced)
|
||||
|
||||
sep = self.conf('foldersep') if folder else self.conf('separator')
|
||||
|
||||
@@ -15,6 +15,7 @@ import re
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from six.moves import filter, map, zip
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -187,7 +188,7 @@ class Scanner(Plugin):
|
||||
|
||||
# Group files minus extension
|
||||
ignored_identifiers = []
|
||||
for identifier, group in movie_files.iteritems():
|
||||
for identifier, group in movie_files.items():
|
||||
if identifier not in group['identifiers'] and len(identifier) > 0: group['identifiers'].append(identifier)
|
||||
|
||||
log.debug('Grouping files: %s', identifier)
|
||||
@@ -228,7 +229,7 @@ class Scanner(Plugin):
|
||||
|
||||
# Group the files based on the identifier
|
||||
delete_identifiers = []
|
||||
for identifier, found_files in path_identifiers.iteritems():
|
||||
for identifier, found_files in path_identifiers.items():
|
||||
log.debug('Grouping files on identifier: %s', identifier)
|
||||
|
||||
group = movie_files.get(identifier)
|
||||
@@ -251,7 +252,7 @@ class Scanner(Plugin):
|
||||
|
||||
# Group based on folder
|
||||
delete_identifiers = []
|
||||
for identifier, found_files in path_identifiers.iteritems():
|
||||
for identifier, found_files in path_identifiers.items():
|
||||
log.debug('Grouping files on foldername: %s', identifier)
|
||||
|
||||
for ff in found_files:
|
||||
|
||||
@@ -108,7 +108,7 @@ class StatusPlugin(Plugin):
|
||||
|
||||
db = get_session()
|
||||
|
||||
for identifier, label in self.statuses.iteritems():
|
||||
for identifier, label in self.statuses.items():
|
||||
s = db.query(Status).filter_by(identifier = identifier).first()
|
||||
if not s:
|
||||
log.info('Creating status: %s', label)
|
||||
|
||||
@@ -45,7 +45,7 @@ class Subtitle(Plugin):
|
||||
if self.isDisabled(): return
|
||||
|
||||
try:
|
||||
available_languages = sum(group['subtitle_language'].itervalues(), [])
|
||||
available_languages = sum(group['subtitle_language'].values(), [])
|
||||
downloaded = []
|
||||
files = [toUnicode(x) for x in group['files']['movie']]
|
||||
log.debug('Searching for subtitles for: %s', files)
|
||||
|
||||
Reference in New Issue
Block a user