python3 only, stop using six

This commit is contained in:
j 2016-10-13 15:19:15 +02:00
parent 2f5f0dc864
commit d5902e2437
6 changed files with 13 additions and 16 deletions

View file

@ -4,8 +4,8 @@ from __future__ import division, print_function, absolute_import
import os.path import os.path
import hashlib import hashlib
import urllib
from six.moves import urllib
from django.db import models from django.db import models
from django.core.files.base import ContentFile from django.core.files.base import ContentFile

View file

@ -3,7 +3,7 @@
from __future__ import division, print_function, absolute_import from __future__ import division, print_function, absolute_import
import os import os
from six.moves.urllib.parse import quote from urllib.parse import quote
from django.db import models from django.db import models

View file

@ -5,14 +5,12 @@ from __future__ import division, print_function, absolute_import
import re import re
import os import os
import unicodedata import unicodedata
from six.moves.urllib.parse import quote from urllib.parse import quote
from six import string_types
import hashlib import hashlib
import base64 import base64
import binascii import binascii
import json import json
from six import string_types
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
import ox import ox
@ -24,7 +22,7 @@ from poster.models import getPosters
def normalize_value(value): def normalize_value(value):
if isinstance(value, bytes): if isinstance(value, bytes):
value = value.decode('utf-8') value = value.decode('utf-8')
if isinstance(value, string_types): if isinstance(value, str):
value = unicodedata.normalize('NFD', value) value = unicodedata.normalize('NFD', value)
return value return value
@ -39,12 +37,12 @@ def find(info, guess=True):
else: else:
for key in Imdb.keys: for key in Imdb.keys:
if key in info and info[key]: if key in info and info[key]:
if isinstance(info[key], string_types): if isinstance(info[key], str):
fkey = '%s__iexact'%key fkey = '%s__iexact' % key
else: else:
fkey = key fkey = key
if isinstance(info[key], list): if isinstance(info[key], list):
fkey = '%s__iexact'%key fkey = '%s__iexact' % key
value = normalize_value('\n'.join(info[key]) + '\n') value = normalize_value('\n'.join(info[key]) + '\n')
else: else:
value = normalize_value(info[key]) value = normalize_value(info[key])
@ -121,7 +119,7 @@ class Imdb(models.Model):
value = info[key] value = info[key]
if isinstance(value, list): if isinstance(value, list):
value = '\n'.join(value) + '\n' value = '\n'.join(value) + '\n'
if isinstance(value, string_types): if isinstance(value, str):
value = normalize_value(value) value = normalize_value(value)
setattr(self, key, value) setattr(self, key, value)
if self.season and self.season < 0: if self.season and self.season < 0:
@ -230,7 +228,7 @@ class Imdb(models.Model):
for key in list(j): for key in list(j):
if not j[key]: if not j[key]:
del j[key] del j[key]
if 'year' in j and isinstance(j['year'], string_types) and j['year'].isdigit(): if 'year' in j and isinstance(j['year'], str) and j['year'].isdigit():
j['year'] = int(j['year']) j['year'] = int(j['year'])
return j return j

View file

@ -6,7 +6,6 @@ import copy
from django.db import models from django.db import models
from django.utils import datetime_safe from django.utils import datetime_safe
from six import string_types
from ox.utils import json from ox.utils import json
@ -73,7 +72,7 @@ class DictField(models.TextField):
if isinstance(value, self._type): if isinstance(value, self._type):
value = self.dumps(value) value = self.dumps(value)
if value is not None: if value is not None:
assert isinstance(value, string_types) assert isinstance(value, str)
value = models.TextField.get_prep_value(self, value) value = models.TextField.get_prep_value(self, value)
return value return value

View file

@ -3,7 +3,7 @@
import os import os
import mimetypes import mimetypes
from datetime import datetime, timedelta from datetime import datetime, timedelta
from six.moves.urllib.parse import quote from urllib.parse import quote
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404
from django.conf import settings from django.conf import settings

View file

@ -2,11 +2,11 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, print_function, absolute_import from __future__ import division, print_function, absolute_import
import os.path
import hashlib import hashlib
import os.path
import socket import socket
import urllib
from six.moves import urllib
from django.db import models from django.db import models
import ox import ox