towards supporting python 2 and 3

- use absolute_imports
- make use of six.moves
- use exec instead of execfile
- use list(dict) instead if dict.keys()
This commit is contained in:
j 2016-08-23 12:27:06 +02:00
commit 1468ddbecb
89 changed files with 400 additions and 265 deletions

View file

@ -2,6 +2,7 @@
# vi:si:et:sw=4:sts=4:ts=4
import unicodedata
from six import string_types
from django.db.models import Q, Manager
from item.utils import decode_id
@ -56,7 +57,7 @@ def parseCondition(condition, user):
else:
key = k + get_operator(op, 'istr')
key = str(key)
if isinstance(v, unicode):
if isinstance(v, string_types):
v = unicodedata.normalize('NFKD', v).lower()
if exclude:
q = ~Q(**{key: v})

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, with_statement
from __future__ import division, print_function, absolute_import
import unicodedata
@ -12,8 +12,7 @@ import ox
from item import utils
import item.models
import managers
import tasks
from . import managers
def get_name_sort(name, sortname=None):
name = unicodedata.normalize('NFKD', name).strip()
@ -95,7 +94,7 @@ class Person(models.Model):
'numberofnames': self.numberofnames,
}
if keys:
for key in j.keys():
for key in list(j):
if key not in keys:
del j[key]
return j

View file

@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division, print_function, absolute_import
from celery.task import task
import models
from . import models
@task(ignore_results=True, queue='default')

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from __future__ import division
from __future__ import division, print_function, absolute_import
import ox
from ox.utils import json
@ -11,8 +11,8 @@ from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json,
from oxdjango.api import actions
from item import utils
import models
import tasks
from . import models
from . import tasks
from user.decorators import capability_required_json
from changelog.models import add_changelog