forked from 0x2620/pandora
python3 only: remove six.moves imports
This commit is contained in:
parent
844382b1e8
commit
548a73f121
33 changed files with 75 additions and 121 deletions
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
from oxdjango.query import QuerySet
|
||||
|
||||
|
@ -68,7 +67,7 @@ def parseCondition(condition, user):
|
|||
else:
|
||||
key = k + get_operator(op, 'istr' if k in case_insensitive_keys else 'str')
|
||||
key = str(key)
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v)
|
||||
if k not in case_sensitive_keys:
|
||||
v = v.lower()
|
||||
|
|
|
@ -9,8 +9,8 @@ import sys
|
|||
import time
|
||||
from os.path import dirname, exists, join
|
||||
from glob import glob
|
||||
import _thread as thread
|
||||
|
||||
from six.moves import _thread as thread
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import copy
|
||||
from datetime import datetime
|
||||
|
||||
from six import string_types
|
||||
from django.shortcuts import render, redirect
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
|
@ -113,7 +112,7 @@ def getPage(request, data):
|
|||
}
|
||||
see: editPage
|
||||
'''
|
||||
if isinstance(data, string_types):
|
||||
if isinstance(data, str):
|
||||
name = data
|
||||
else:
|
||||
name = data['name']
|
||||
|
|
|
@ -12,7 +12,6 @@ import shutil
|
|||
from distutils.spawn import find_executable
|
||||
from glob import glob
|
||||
|
||||
from six import string_types
|
||||
import numpy as np
|
||||
import ox
|
||||
import ox.image
|
||||
|
@ -463,7 +462,7 @@ def timeline(video, prefix, modes=None, size=None):
|
|||
modes = ['antialias', 'slitscan', 'keyframes', 'audio', 'data']
|
||||
if size is None:
|
||||
size = [64, 16]
|
||||
if isinstance(video, string_types):
|
||||
if isinstance(video, str):
|
||||
video = [video]
|
||||
cmd = ['../bin/oxtimelines',
|
||||
'-s', ','.join(map(str, reversed(sorted(size)))),
|
||||
|
|
|
@ -6,7 +6,6 @@ import shutil
|
|||
import tempfile
|
||||
import time
|
||||
|
||||
from six import string_types, PY2
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
|
@ -28,9 +27,6 @@ from . import managers
|
|||
|
||||
User = get_user_model()
|
||||
|
||||
if not PY2:
|
||||
unicode = str
|
||||
|
||||
def data_path(f, x):
|
||||
return f.get_path('data.bin')
|
||||
|
||||
|
@ -165,7 +161,7 @@ class File(models.Model):
|
|||
if self.item:
|
||||
for key in self.ITEM_INFO:
|
||||
data[key] = self.item.get(key)
|
||||
if isinstance(data[key], string_types):
|
||||
if isinstance(data[key], str):
|
||||
data[key] = ox.decode_html(data[key])
|
||||
elif isinstance(data[key], list):
|
||||
data[key] = [ox.decode_html(e) for e in data[key]]
|
||||
|
@ -259,8 +255,8 @@ class File(models.Model):
|
|||
data = self.get_path_info()
|
||||
self.extension = data.get('extension')
|
||||
self.language = data.get('language')
|
||||
self.part = ox.sort_string(unicode(data.get('part') or ''))
|
||||
self.part_title = ox.sort_string(unicode(data.get('partTitle')) or '')
|
||||
self.part = ox.sort_string(str(data.get('part') or ''))
|
||||
self.part_title = ox.sort_string(str(data.get('partTitle')) or '')
|
||||
self.type = data.get('type') or 'unknown'
|
||||
self.version = data.get('version')
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from glob import glob
|
||||
|
||||
from six import string_types
|
||||
from celery.task import task
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
@ -219,7 +218,7 @@ def move_media(data, user):
|
|||
data['public_id'] = data.pop('item').strip()
|
||||
if not is_imdb_id(data['public_id']):
|
||||
del data['public_id']
|
||||
if 'director' in data and isinstance(data['director'], string_types):
|
||||
if 'director' in data and isinstance(data['director'], str):
|
||||
if data['director'] == '':
|
||||
data['director'] = []
|
||||
else:
|
||||
|
|
|
@ -7,7 +7,6 @@ from django.shortcuts import get_object_or_404, redirect, render
|
|||
from django.conf import settings
|
||||
from django.db.models import Count, Q
|
||||
|
||||
from six import string_types
|
||||
from celery.utils import get_full_cls_name
|
||||
from celery._state import current_app
|
||||
import ox
|
||||
|
@ -555,7 +554,7 @@ def getPath(request, data):
|
|||
'''
|
||||
response = json_response()
|
||||
ids = data['id']
|
||||
if isinstance(ids, string_types):
|
||||
if isinstance(ids, str):
|
||||
ids = [ids]
|
||||
for f in models.File.objects.filter(oshash__in=ids).values('path', 'oshash').order_by('sort_path'):
|
||||
response['data'][f['oshash']] = f['path']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -78,7 +77,7 @@ def parseCondition(condition, user):
|
|||
else:
|
||||
key = k + get_operator(op, 'istr' if k in case_insensitive_keys else 'str')
|
||||
key = str(key)
|
||||
if isinstance(v, string_types) and op != '===':
|
||||
if isinstance(v, str) and op != '===':
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
|
@ -155,7 +154,7 @@ class ClipManager(Manager):
|
|||
def parse(condition):
|
||||
key = 'findvalue' + get_operator(condition.get('operator', ''))
|
||||
v = condition['value']
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
q = Q(**{key: v})
|
||||
if condition['key'] in layer_ids:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -152,7 +151,7 @@ def buildCondition(k, op, v, user, exclude=False, owner=None):
|
|||
value_key = 'find__value'
|
||||
else:
|
||||
value_key = k
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if k in facet_keys:
|
||||
in_find = False
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from glob import glob
|
||||
from urllib.parse import quote, unquote
|
||||
import os
|
||||
import re
|
||||
from glob import glob
|
||||
import unicodedata
|
||||
|
||||
from six import PY2, string_types
|
||||
from six.moves.urllib.parse import quote, unquote
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Q, Sum, Max
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -34,9 +33,6 @@ from .fulltext import FulltextMixin
|
|||
|
||||
User = get_user_model()
|
||||
|
||||
if not PY2:
|
||||
unicode = str
|
||||
|
||||
def get_path(f, x):
|
||||
return f.path(x)
|
||||
|
||||
|
@ -88,7 +84,7 @@ class Document(models.Model, FulltextMixin):
|
|||
if not current_values:
|
||||
current_values = []
|
||||
else:
|
||||
current_values = [unicode(current_values)]
|
||||
current_values = [str(current_values)]
|
||||
|
||||
filter_map = utils.get_by_id(settings.CONFIG['documentKeys'], key).get('filterMap')
|
||||
if filter_map:
|
||||
|
@ -139,7 +135,7 @@ class Document(models.Model, FulltextMixin):
|
|||
f, created = Find.objects.get_or_create(document=self, key=key)
|
||||
if isinstance(value, bool):
|
||||
value = value and 'true' or 'false'
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.decode_html(ox.strip_tags(value.strip()))
|
||||
value = unicodedata.normalize('NFKD', value).lower()
|
||||
f.value = value
|
||||
|
@ -197,7 +193,7 @@ class Document(models.Model, FulltextMixin):
|
|||
return sort_value.lower()
|
||||
|
||||
def set_value(s, name, value):
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.decode_html(value.lower())
|
||||
if not value:
|
||||
value = None
|
||||
|
@ -259,7 +255,7 @@ class Document(models.Model, FulltextMixin):
|
|||
set_value(s, name, value)
|
||||
elif sort_type == 'date':
|
||||
value = self.get_value(source)
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = datetime_safe.datetime.strptime(value, '%Y-%m-%d')
|
||||
set_value(s, name, value)
|
||||
s.save()
|
||||
|
@ -370,11 +366,11 @@ class Document(models.Model, FulltextMixin):
|
|||
self.data[key] = [ox.sanitize_html(t) for t in data[key]]
|
||||
elif ktype == '[string]':
|
||||
self.data[key] = [ox.escape_html(t) for t in data[key]]
|
||||
elif isinstance(data[key], string_types):
|
||||
elif isinstance(data[key], str):
|
||||
self.data[key] = ox.escape_html(data[key])
|
||||
elif isinstance(data[key], list):
|
||||
def cleanup(i):
|
||||
if isinstance(i, string_types):
|
||||
if isinstance(i, str):
|
||||
i = ox.escape_html(i)
|
||||
return i
|
||||
self.data[key] = [cleanup(i) for i in data[key]]
|
||||
|
@ -480,7 +476,7 @@ class Document(models.Model, FulltextMixin):
|
|||
if self.extension == 'html':
|
||||
response['text'] = self.data.get('text', '')
|
||||
if item:
|
||||
if isinstance(item, string_types):
|
||||
if isinstance(item, str):
|
||||
item = Item.objects.get(public_id=item)
|
||||
d = self.descriptions.filter(item=item)
|
||||
if d.exists():
|
||||
|
|
|
@ -5,7 +5,6 @@ import re
|
|||
from glob import glob
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
import ox
|
||||
from ox.utils import json
|
||||
from oxdjango.api import actions
|
||||
|
@ -70,7 +69,7 @@ def addDocument(request, data):
|
|||
else:
|
||||
ids = [data['id']]
|
||||
if 'item' in data:
|
||||
if isinstance(data['item'], string_types):
|
||||
if isinstance(data['item'], str):
|
||||
item = Item.objects.get(public_id=data['item'])
|
||||
if item.editable(request.user):
|
||||
for id in ids:
|
||||
|
@ -87,7 +86,7 @@ def addDocument(request, data):
|
|||
document.add(item)
|
||||
add_changelog(request, data, data['item'])
|
||||
elif 'entity' in data:
|
||||
if isinstance(data['entity'], string_types):
|
||||
if isinstance(data['entity'], str):
|
||||
entity = Entity.get(data['entity'])
|
||||
if entity.editable(request.user):
|
||||
for id in ids:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import os
|
||||
import shutil
|
||||
from glob import glob
|
||||
from urllib.parse import quote
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
import ox
|
||||
from django.conf import settings
|
||||
from django.db import models, transaction
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from glob import glob
|
||||
from urllib.parse import quote, unquote
|
||||
import os
|
||||
import re
|
||||
from glob import glob
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from six.moves.urllib.parse import quote, unquote
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Max
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -188,7 +187,7 @@ class Entity(models.Model):
|
|||
.delete()
|
||||
else:
|
||||
#FIXME: more data validation
|
||||
if isinstance(data[key], string_types):
|
||||
if isinstance(data[key], str):
|
||||
self.data[key] = ox.sanitize_html(data[key])
|
||||
else:
|
||||
self.data[key] = data[key]
|
||||
|
@ -275,7 +274,7 @@ class Entity(models.Model):
|
|||
f, created = Find.objects.get_or_create(entity=self, key=key)
|
||||
if isinstance(value, bool):
|
||||
value = value and 'true' or 'false'
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.decode_html(ox.strip_tags(value.strip()))
|
||||
value = unicodedata.normalize('NFKD', value).lower()
|
||||
f.value = value
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from six import string_types
|
||||
import ox
|
||||
from ox.utils import json
|
||||
from oxdjango.api import actions
|
||||
|
@ -69,7 +68,7 @@ def addEntity(request, data):
|
|||
for key in ('type', 'alternativeNames'):
|
||||
if key in data and data[key]:
|
||||
value = data[key]
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.escape_html(value)
|
||||
if key == 'alternativeNames':
|
||||
value = tuple([ox.escape_html(v) for v in value])
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
|
||||
from oxdjango.query import QuerySet
|
||||
|
@ -30,7 +29,7 @@ def parseCondition(condition, user):
|
|||
|
||||
key = k + get_operator(op, 'istr')
|
||||
key = str(key)
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{k: v})
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from django.db.models import Count
|
||||
from django.conf import settings
|
||||
|
||||
from six import string_types
|
||||
import ox
|
||||
from ox.utils import json
|
||||
|
||||
|
@ -47,7 +46,7 @@ def addEvent(request, data):
|
|||
'type', 'alternativeNames'):
|
||||
if key in data and data[key]:
|
||||
value = data[key]
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.escape_html(value)
|
||||
if key == 'alternativeNames':
|
||||
value = tuple([ox.escape_html(v) for v in value])
|
||||
|
@ -101,7 +100,7 @@ def editEvent(request, data):
|
|||
'type', 'alternativeNames'):
|
||||
if key in data:
|
||||
value = data[key]
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.escape_html(value)
|
||||
if key == 'alternativeNames':
|
||||
value = tuple([ox.escape_html(v) for v in value])
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from six import string_types
|
||||
from six.moves.urllib.parse import quote
|
||||
from urllib.parse import quote
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Max
|
||||
|
@ -43,7 +42,7 @@ class Item(models.Model):
|
|||
len([d for d in data[key] if isinstance(d, int)]) == 4):
|
||||
return False
|
||||
else:
|
||||
if not isinstance(data[key], string_types):
|
||||
if not isinstance(data[key], str):
|
||||
return False
|
||||
self.data[key] = data[key]
|
||||
if key == 'contentid' and self.data[key]:
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from datetime import datetime
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -123,7 +122,7 @@ def parseCondition(condition, user, owner=None):
|
|||
else:
|
||||
value_key = k
|
||||
if not k.startswith('public_id'):
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if k in facet_keys:
|
||||
in_find = False
|
||||
|
|
|
@ -10,9 +10,7 @@ import unicodedata
|
|||
import uuid
|
||||
from datetime import datetime
|
||||
from glob import glob
|
||||
|
||||
from six import PY2, string_types
|
||||
from six.moves.urllib.parse import quote
|
||||
from urllib.parse import quote
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -46,8 +44,6 @@ import archive.models
|
|||
|
||||
User = get_user_model()
|
||||
|
||||
if not PY2:
|
||||
unicode = str
|
||||
|
||||
def get_id(info):
|
||||
q = Item.objects.all()
|
||||
|
@ -284,11 +280,11 @@ class Item(models.Model):
|
|||
self.data[key] = [ox.escape_html(t) for t in data[key]]
|
||||
elif key in ('episodeTitle', 'seriesTitle', 'episodeDirector', 'seriesYear'):
|
||||
self.data[key] = ox.escape_html(data[key])
|
||||
elif isinstance(data[key], string_types):
|
||||
elif isinstance(data[key], str):
|
||||
self.data[key] = ox.escape_html(data[key])
|
||||
elif isinstance(data[key], list):
|
||||
def cleanup(i):
|
||||
if isinstance(i, string_types):
|
||||
if isinstance(i, str):
|
||||
i = ox.escape_html(i)
|
||||
return i
|
||||
self.data[key] = [cleanup(i) for i in data[key]]
|
||||
|
@ -329,7 +325,7 @@ class Item(models.Model):
|
|||
if c:
|
||||
for t in list(c):
|
||||
if c[t]:
|
||||
if isinstance(c[t][0], string_types):
|
||||
if isinstance(c[t][0], str):
|
||||
c[t] = [{'id': i, 'title': None} for i in c[t]]
|
||||
ids = [i['id'] for i in c[t]]
|
||||
known = {}
|
||||
|
@ -626,7 +622,7 @@ class Item(models.Model):
|
|||
if value:
|
||||
i[key] = value
|
||||
|
||||
if 'cast' in i and isinstance(i['cast'][0], string_types):
|
||||
if 'cast' in i and isinstance(i['cast'][0], str):
|
||||
i['cast'] = [i['cast']]
|
||||
if 'cast' in i and isinstance(i['cast'][0], list):
|
||||
i['cast'] = [{'actor': x[0], 'character': x[1]} for x in i['cast']]
|
||||
|
@ -797,7 +793,7 @@ class Item(models.Model):
|
|||
f, created = ItemFind.objects.get_or_create(item=self, key=key)
|
||||
if isinstance(value, bool):
|
||||
value = value and 'true' or 'false'
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.decode_html(ox.strip_tags(value.strip()))
|
||||
value = unicodedata.normalize('NFKD', value).lower()
|
||||
f.value = value
|
||||
|
@ -916,7 +912,7 @@ class Item(models.Model):
|
|||
return sort_value.lower()
|
||||
|
||||
def set_value(s, name, value):
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.decode_html(value.lower())
|
||||
if not value:
|
||||
value = None
|
||||
|
@ -1052,7 +1048,7 @@ class Item(models.Model):
|
|||
set_value(s, name, value)
|
||||
elif sort_type == 'date':
|
||||
value = value_ = self.get(source)
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value_ = None
|
||||
for fmt in ('%Y-%m-%d', '%Y-%m', '%Y'):
|
||||
try:
|
||||
|
@ -1091,7 +1087,7 @@ class Item(models.Model):
|
|||
if not current_values:
|
||||
current_values = []
|
||||
else:
|
||||
current_values = [unicode(current_values)]
|
||||
current_values = [str(current_values)]
|
||||
|
||||
filter_map = utils.get_by_id(settings.CONFIG['itemKeys'], key).get('filterMap')
|
||||
if filter_map:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from datetime import timedelta, datetime
|
||||
from urllib.parse import quote
|
||||
import gzip
|
||||
import os
|
||||
import random
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
from celery.task import task, periodic_task
|
||||
from django.conf import settings
|
||||
from django.db import connection, transaction
|
||||
|
|
|
@ -6,7 +6,6 @@ import unicodedata
|
|||
|
||||
import ox
|
||||
from ox import sort_string
|
||||
from six import PY2
|
||||
|
||||
|
||||
def safe_filename(filename):
|
||||
|
@ -92,11 +91,7 @@ def get_by_id(objects, id):
|
|||
return get_by_key(objects, 'id', id)
|
||||
|
||||
def normalize_dict(encoding, data):
|
||||
if PY2:
|
||||
string_type = unicode
|
||||
else:
|
||||
string_type = str
|
||||
if isinstance(data, string_type):
|
||||
if isinstance(data, str):
|
||||
data = unicodedata.normalize(encoding, data)
|
||||
elif isinstance(data, dict):
|
||||
for key in data:
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os.path
|
||||
from datetime import datetime, timedelta
|
||||
from urllib.parse import quote, urlparse
|
||||
import mimetypes
|
||||
import os.path
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from six import PY2
|
||||
from six.moves.urllib.parse import quote, urlparse
|
||||
from PIL import Image
|
||||
from django.db.models import Count, Sum
|
||||
from django.http import HttpResponse, HttpResponseForbidden, Http404
|
||||
|
@ -35,8 +34,6 @@ from changelog.models import add_changelog
|
|||
|
||||
from oxdjango.api import actions
|
||||
|
||||
if not PY2:
|
||||
unicode = str
|
||||
|
||||
def _order_query(qs, sort, prefix='sort__'):
|
||||
order_by = []
|
||||
|
@ -1280,7 +1277,7 @@ def atom_xml(request):
|
|||
}.get(key, key))
|
||||
if value and value != -1:
|
||||
el = ET.SubElement(format, key)
|
||||
el.text = unicode(value)
|
||||
el.text = str(value)
|
||||
el = ET.SubElement(format, 'pixel_aspect_ratio')
|
||||
el.text = "1:1"
|
||||
|
||||
|
@ -1357,7 +1354,7 @@ def oembed(request):
|
|||
oxml = ET.Element('oembed')
|
||||
for key in oembed:
|
||||
e = ET.SubElement(oxml, key)
|
||||
e.text = unicode(oembed[key])
|
||||
e.text = str(oembed[key])
|
||||
return HttpResponse(
|
||||
'<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n' + ET.tostring(oxml).decode(),
|
||||
'application/xml'
|
||||
|
@ -1423,7 +1420,7 @@ def item_xml(request, id):
|
|||
xmltree(root, k, data[k])
|
||||
else:
|
||||
e = ET.SubElement(root, key)
|
||||
e.text = unicode(data)
|
||||
e.text = str(data)
|
||||
|
||||
oxml = ET.Element('item')
|
||||
xmltree(oxml, 'item', j)
|
||||
|
@ -1483,7 +1480,7 @@ def item(request, id):
|
|||
else:
|
||||
title = key['title'] if key else k.capitalize()
|
||||
if isinstance(value, list):
|
||||
value = value = ', '.join([unicode(v) for v in value])
|
||||
value = value = ', '.join([str(v) for v in value])
|
||||
elif key and key.get('type') == 'float':
|
||||
value = '%0.3f' % value
|
||||
elif key and key.get('type') == 'time':
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import
|
|||
import inspect
|
||||
import sys
|
||||
|
||||
from six import PY2
|
||||
from django.conf import settings
|
||||
|
||||
from ..shortcuts import render_to_json_response, json_response
|
||||
|
@ -109,12 +108,8 @@ class ApiActions(dict):
|
|||
if name != 'api' and hasattr(f, 'func_closure') and f.func_closure:
|
||||
fc = list(filter(lambda c: hasattr(c.cell_contents, '__call__'), f.func_closure))
|
||||
f = fc[len(fc)-1].cell_contents
|
||||
if PY2:
|
||||
info = f.func_code.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = '%s:%s' % (info, f.func_code.co_firstlineno)
|
||||
else:
|
||||
info = f.__code__.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = '%s:%s' % (info, f.__code__.co_firstlineno)
|
||||
info = f.__code__.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = '%s:%s' % (info, f.__code__.co_firstlineno)
|
||||
return info, trim(inspect.getsource(f))
|
||||
|
||||
def register(self, method, action=None, cache=True, version=None):
|
||||
|
|
|
@ -8,8 +8,6 @@ from django.utils import datetime_safe
|
|||
import django.contrib.postgres.fields
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
||||
from six import string_types
|
||||
|
||||
from ox.utils import json
|
||||
|
||||
class JSONField(django.contrib.postgres.fields.JSONField):
|
||||
|
@ -74,7 +72,7 @@ class DictField(models.TextField):
|
|||
except:
|
||||
raise Exception('failed to parse value: %s' % value)
|
||||
if value is not None:
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = json.loads(value)
|
||||
assert isinstance(value, self._type)
|
||||
return value
|
||||
|
@ -83,7 +81,7 @@ class DictField(models.TextField):
|
|||
if isinstance(value, self._type):
|
||||
value = self.dumps(value)
|
||||
if value is not None:
|
||||
assert isinstance(value, string_types)
|
||||
assert isinstance(value, str)
|
||||
value = models.TextField.get_prep_value(self, value)
|
||||
return value
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import mimetypes
|
||||
from datetime import datetime, timedelta
|
||||
from six.moves.urllib.parse import quote
|
||||
from urllib.parse import quote
|
||||
import mimetypes
|
||||
import os
|
||||
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.conf import settings
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
|
||||
from item.utils import decode_id
|
||||
|
@ -56,7 +55,7 @@ def parseCondition(condition, user):
|
|||
else:
|
||||
key = k + get_operator(op, 'istr')
|
||||
key = str(key)
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
|
||||
from item.utils import decode_id
|
||||
|
@ -55,7 +54,7 @@ def parseCondition(condition, user):
|
|||
key = k + get_operator(op, 'istr')
|
||||
|
||||
key = str(key)
|
||||
if isinstance(v, string_types):
|
||||
if isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
|
||||
if exclude:
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from django.db.models import Max, Min, Count
|
||||
from django.conf import settings
|
||||
|
||||
from six import string_types
|
||||
import ox
|
||||
from ox.utils import json
|
||||
|
||||
|
@ -115,7 +114,7 @@ def editPlace(request, data):
|
|||
'''
|
||||
place = get_object_or_404_json(models.Place, pk=ox.fromAZ(data['id']))
|
||||
names = data.get('name', [])
|
||||
if isinstance(names, string_types):
|
||||
if isinstance(names, str):
|
||||
names = [names]
|
||||
names = [ox.escape_html(n) for n in names]
|
||||
alternative_names = [ox.escape_html(n) for n in data.get('alternativeNames', [])]
|
||||
|
@ -144,7 +143,7 @@ def editPlace(request, data):
|
|||
for key in data:
|
||||
if key != 'id':
|
||||
value = data[key]
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
value = ox.escape_html(value)
|
||||
if isinstance(value, list):
|
||||
value = tuple(value)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from six import string_types
|
||||
from django.db import connection, transaction
|
||||
from celery.task import task
|
||||
|
||||
|
@ -30,7 +29,7 @@ def get_sequences(public_id):
|
|||
sequence['duration'] = sequence['end'] - sequence['start']
|
||||
if not keys:
|
||||
keys = ', '.join(['"%s"'%k for k in sequence.keys()])
|
||||
v = ', '.join([isinstance(v, string_types) and "'%s'"%v or str(v)
|
||||
v = ', '.join([isinstance(v, str) and "'%s'"%v or str(v)
|
||||
for v in sequence.values()])
|
||||
values.append('(%s)'%v)
|
||||
if values:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from glob import glob
|
||||
from urllib.parse import quote
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from glob import glob
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
from django.db import models
|
||||
from django.db.models import Max
|
||||
from django.contrib.auth import get_user_model
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unicodedata
|
||||
|
||||
from six import string_types
|
||||
from django.db.models import Q, Manager
|
||||
|
||||
from item.utils import decode_id
|
||||
|
@ -47,7 +46,7 @@ def parseCondition(condition, user):
|
|||
return q
|
||||
if k == 'id':
|
||||
v = decode_id(v)
|
||||
elif isinstance(v, string_types):
|
||||
elif isinstance(v, str):
|
||||
v = unicodedata.normalize('NFKD', v).lower()
|
||||
if isinstance(v, bool):
|
||||
key = k
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from urllib.parse import quote
|
||||
import re
|
||||
|
||||
from six.moves.urllib.parse import quote
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
|
||||
import app.views
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
from datetime import timedelta
|
||||
from itertools import zip_longest
|
||||
import json
|
||||
|
||||
from six.moves import zip_longest
|
||||
from celery.task import task, periodic_task
|
||||
|
||||
from app.utils import limit_rate
|
||||
|
|
Loading…
Reference in a new issue