basestring->six.string_types
This commit is contained in:
parent
fa29557a6f
commit
1db297169b
4 changed files with 11 additions and 5 deletions
|
@ -4,7 +4,7 @@
|
|||
import re
|
||||
import string
|
||||
from six.moves.html_entities import name2codepoint
|
||||
from six import unichr, PY2
|
||||
from six import unichr, PY2, string_types
|
||||
|
||||
|
||||
# Configuration for add_links() function
|
||||
|
@ -34,7 +34,7 @@ def escape(html):
|
|||
>>> escape('html "test" & <brothers>')
|
||||
'html "test" & <brothers>'
|
||||
'''
|
||||
if not isinstance(html, basestring):
|
||||
if not isinstance(html, string_types):
|
||||
html = str(html)
|
||||
return html.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''')
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
import re
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
|
||||
|
||||
_articles = ('the', 'la', 'a', 'die', 'der', 'le', 'el',
|
||||
"l'", 'il', 'das', 'les', 'o', 'ein', 'i', 'un', 'los', 'de',
|
||||
'an', 'una', 'las', 'eine', 'den', 'gli', 'het', 'os', 'lo',
|
||||
|
@ -95,7 +98,7 @@ def normalize_imdbid(imdbId):
|
|||
>>> normalize_imdbid('tt0159206')
|
||||
'0159206'
|
||||
"""
|
||||
if isinstance(imdbId, basestring):
|
||||
if isinstance(imdbId, string_types):
|
||||
imdbId = re.sub('.*(\d{7}).*', '\\1', imdbId)
|
||||
elif isinstance(imdbId, int):
|
||||
imdbId = "%07d" % imdbId
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue