Six import

This commit is contained in:
Ruud
2014-10-06 23:01:47 +02:00
parent e1eb68e226
commit 6c2aef7a6d
7 changed files with 12 additions and 8 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ def getParams(params):
for item in nested: for item in nested:
if item is nested[-1]: if item is nested[-1]:
current[item] = toUnicode(urllib.unquote(value)) current[item] = toUnicode(urllib.parse.unquote(value))
else: else:
try: try:
current[item] current[item]
@@ -37,7 +37,7 @@ def getParams(params):
current = current[item] current = current[item]
else: else:
temp[param] = toUnicode(urllib.unquote(value)) temp[param] = toUnicode(urllib.parse.unquote(value))
if temp[param].lower() in ['true', 'false']: if temp[param].lower() in ['true', 'false']:
temp[param] = temp[param].lower() != 'false' temp[param] = temp[param].lower() != 'false'
+1 -1
View File
@@ -89,7 +89,7 @@ class MediaBase(Plugin):
# Loop over type # Loop over type
for image in image_urls.get(image_type, []): for image in image_urls.get(image_type, []):
if not isinstance(image, (str, unicode)): if not isinstance(image, six.string_types):
continue continue
if file_type not in existing_files or len(existing_files.get(file_type, [])) == 0: if file_type not in existing_files or len(existing_files.get(file_type, [])) == 0:
+2 -1
View File
@@ -12,6 +12,7 @@ from couchpotato.core.helpers.variable import splitString, getImdb, getTitle
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.media import MediaBase from couchpotato.core.media import MediaBase
from .index import MediaIndex, MediaStatusIndex, MediaTypeIndex, TitleSearchIndex, TitleIndex, StartsWithIndex, MediaChildrenIndex, MediaTagIndex from .index import MediaIndex, MediaStatusIndex, MediaTypeIndex, TitleSearchIndex, TitleIndex, StartsWithIndex, MediaChildrenIndex, MediaTagIndex
import six
log = CPLog(__name__) log = CPLog(__name__)
@@ -280,7 +281,7 @@ class MediaPlugin(MediaBase):
offset = 0 offset = 0
limit = -1 limit = -1
if limit_offset: if limit_offset:
splt = splitString(limit_offset) if isinstance(limit_offset, (str, unicode)) else limit_offset splt = splitString(limit_offset) if isinstance(limit_offset, six.string_types) else limit_offset
limit = tryInt(splt[0]) limit = tryInt(splt[0])
offset = tryInt(0 if len(splt) is 1 else splt[1]) offset = tryInt(0 if len(splt) is 1 else splt[1])
+2 -1
View File
@@ -3,6 +3,7 @@ from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.helpers.variable import mergeDicts, getImdb from couchpotato.core.helpers.variable import mergeDicts, getImdb
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
import six
log = CPLog(__name__) log = CPLog(__name__)
@@ -30,7 +31,7 @@ class Search(Plugin):
def search(self, q = '', types = None, **kwargs): def search(self, q = '', types = None, **kwargs):
# Make sure types is the correct instance # Make sure types is the correct instance
if isinstance(types, (str, unicode)): if isinstance(types, six.string_types):
types = [types] types = [types]
elif isinstance(types, (list, tuple, set)): elif isinstance(types, (list, tuple, set)):
types = list(types) types = list(types)
@@ -7,6 +7,7 @@ from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import tryInt, tryFloat, splitString from couchpotato.core.helpers.variable import tryInt, tryFloat, splitString
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.media.movie.providers.base import MovieProvider from couchpotato.core.media.movie.providers.base import MovieProvider
import six
log = CPLog(__name__) log = CPLog(__name__)
@@ -72,7 +73,7 @@ class OMDBAPI(MovieProvider):
try: try:
try: try:
if isinstance(movie, (str, unicode)): if isinstance(movie, six.string_types):
movie = json.loads(movie) movie = json.loads(movie)
except ValueError: except ValueError:
log.info('No proper json to decode') log.info('No proper json to decode')
+2 -1
View File
@@ -8,6 +8,7 @@ from couchpotato.core.helpers.database import RecordDeleted
from couchpotato.core.helpers.variable import splitString, tryInt from couchpotato.core.helpers.variable import splitString, tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
import six
log = CPLog(__name__) log = CPLog(__name__)
@@ -41,7 +42,7 @@ class Dashboard(Plugin):
# Add limit # Add limit
limit = 12 limit = 12
if limit_offset: if limit_offset:
splt = splitString(limit_offset) if isinstance(limit_offset, (str, unicode)) else limit_offset splt = splitString(limit_offset) if isinstance(limit_offset, six.string_types) else limit_offset
limit = tryInt(splt[0]) limit = tryInt(splt[0])
# Get all active medias # Get all active medias
+1 -1
View File
@@ -30,7 +30,7 @@
# SOFTWARE. # SOFTWARE.
# */ # */
from StringIO import StringIO from six import StringIO
def jsmin(js): def jsmin(js):
ins = StringIO(js) ins = StringIO(js)