basestring->six.string_types

This commit is contained in:
j 2015-12-25 20:38:55 +05:30
commit 1db297169b
4 changed files with 11 additions and 5 deletions

View file

@ -3,6 +3,8 @@
from .. import cache
from ..utils import json
from six import string_types
def get_id(url):
return url.split("/")[-1]
@ -19,7 +21,7 @@ def get_data(id):
data[key] = details['metadata'][key]
if isinstance(data[key], list):
data[key] = data[key][0]
if isinstance(data[key], basestring):
if isinstance(data[key], string_types):
data[key] = data[key].strip()
if data[key][0] == '[' and data[key][-1] == ']':
data[key] = data[key][1:-1]

View file

@ -5,6 +5,7 @@ from __future__ import print_function
import re
from six.moves import urllib
from six import string_types
from ox.utils import json
from ox.cache import read_url
@ -68,7 +69,7 @@ def get_movie_data(wikipedia_url):
value = value.split('<br>')
if value:
if key in filmbox:
if isinstance(value, list) and isinstance(filmbox[key], basestring):
if isinstance(value, list) and isinstance(filmbox[key], string_types):
filmbox[key] = [filmbox[key]] + value
else:
filmbox[key] += value