1. Ivan Zakrevsky
  2. django-imaging

Commits

Ivan Zakrevsky  committed 6eb7a25

2to3

  • Participants
  • Parent commits c2599f2
  • Branches default

Comments (0)

Files changed (10)

File imaging/__init__.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 """
 
 Django Imaging

File imaging/admin.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.contrib import admin
 from imaging.models import Image
 

File imaging/fields.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.db import models
 from django import forms
 from django.utils.translation import ugettext as _
 
     def clean(self, value):
         value = super(CommaSeparatedIntField, self).clean(value)
-        if value == u'':
+        if value == '':
             return value
         for i in value.split(','):
             if len(i) and not i.isdigit():
             pass
 
 
-class ImagingField(models.Field):
-
-    __metaclass__ = models.SubfieldBase
+class ImagingField(models.SubfieldBase(bytes("NewBase"), (models.Field, ), {})):
 
     def __init__(self, *args, **kwargs):
         kwargs['default'] = ''

File imaging/forms.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django import forms
 from imaging.models import Image
 

File imaging/models.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 from django.db import models
 
+try:
+    str = unicode  # Python 2.* compatible
+except NameError:
+    pass
+
 DEFAULT_IMAGING_SETTINGS = {
     'image_dir': 'imaging_photos/%Y/%m/%d',
 }
             ('imaging_delete_images', "Can delete using AJAX"),
         )
 
-    def __unicode__(self):
+    def __str__(self):
         return self.name
 
     def is_allowed(self, user, perm=None):
             return user.has_perm(perm, self.content_object)
         except:
             return False
+
+# Python 2.* compatible
+try:
+    unicode
+except NameError:
+    pass
+else:
+    for cls in (Image, ):
+        cls.__unicode__ = cls.__str__
+        cls.__str__ = lambda self: self.__unicode__().encode('utf-8')

File imaging/tests.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.test import TestCase
 from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
         testfile.close()
 
         self.assertEquals(response.status_code, 200)
-        self.assertTrue(isinstance(response.context['image'].pk, (long, int)))
+        self.assertTrue(bool(response.context['image'].pk))
         os.path.isfile(response.context['image'].image.path)
         os.remove(response.context['image'].image.path)

File imaging/urls.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.conf.urls.defaults import patterns, url
 
 urlpatterns = patterns('imaging.views',

File imaging/views.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.contrib.auth.decorators import login_required
 from django.core.exceptions import PermissionDenied
 from django.http import HttpResponse

File imaging/widgets.py

View file
  • Ignore whitespace
+from __future__ import absolute_import, unicode_literals
 from django.conf import settings
 from django.forms.util import flatatt
 from django.forms.widgets import Widget

File setup.py

View file
  • Ignore whitespace
         'Topic :: Software Development :: Libraries :: Application Frameworks',
         'Topic :: Software Development :: Libraries :: Python Modules',
     ],
-    url = "https://bitbucket.org/evotech/%s" % app_name,
+    url = "https://bitbucket.org/evotech/{0}".format(app_name),
 )