Skip to content

Commit

Permalink
Fix Python 3 compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anrie committed Nov 20, 2013
1 parent 07c02fe commit 5880347
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/models.py
Expand Up @@ -13,7 +13,7 @@ class Meta:


def get_cropping_as_list(self): def get_cropping_as_list(self):
if self.cropping: if self.cropping:
return map(int, self.cropping.split(',')) return list(map(int, self.cropping.split(',')))




class ImageFK(models.Model): class ImageFK(models.Model):
Expand Down
4 changes: 2 additions & 2 deletions image_cropping/fields.py
Expand Up @@ -25,15 +25,15 @@ def south_field_triple(self):
class ImageRatioField(models.CharField): class ImageRatioField(models.CharField):
def __init__(self, image_field, size='0x0', free_crop=False, def __init__(self, image_field, size='0x0', free_crop=False,
adapt_rotation=False, allow_fullsize=False, verbose_name=None, adapt_rotation=False, allow_fullsize=False, verbose_name=None,
help_text=None, hide_image_field=False, help_text=None, hide_image_field=False,
size_warning=getattr( size_warning=getattr(
settings, 'IMAGE_CROPPING_SIZE_WARNING', False)): settings, 'IMAGE_CROPPING_SIZE_WARNING', False)):
if '__' in image_field: if '__' in image_field:
self.image_field, self.image_fk_field = image_field.split('__') self.image_field, self.image_fk_field = image_field.split('__')
else: else:
self.image_field, self.image_fk_field = image_field, None self.image_field, self.image_fk_field = image_field, None


self.width, self.height = map(int, size.split('x')) self.width, self.height = list(map(int, size.split('x')))
self.free_crop = free_crop self.free_crop = free_crop
self.adapt_rotation = adapt_rotation self.adapt_rotation = adapt_rotation
self.allow_fullsize = allow_fullsize self.allow_fullsize = allow_fullsize
Expand Down
4 changes: 2 additions & 2 deletions image_cropping/templatetags/cropping.py
Expand Up @@ -39,7 +39,7 @@ def cropped_thumbnail(parser, token):
raise raise
if not 'x' in value: if not 'x' in value:
raise template.TemplateSyntaxError("%s must match INTxINT" % args[3]) raise template.TemplateSyntaxError("%s must match INTxINT" % args[3])
option = (name, map(int, value.split('x'))) option = (name, list(map(int, value.split('x'))))
else: else:
if not option[0] in ('scale', 'width', 'height'): if not option[0] in ('scale', 'width', 'height'):
raise template.TemplateSyntaxError("invalid optional argument %s" % args[3]) raise template.TemplateSyntaxError("invalid optional argument %s" % args[3])
Expand Down Expand Up @@ -83,7 +83,7 @@ def render(self, context):
if not box: if not box:
size = (image.width, image.height) size = (image.width, image.height)
else: else:
box_values = map(int, box.split(',')) box_values = list(map(int, box.split(',')))
size = (box_values[2] - box_values[0], size = (box_values[2] - box_values[0],
box_values[3] - box_values[1]) box_values[3] - box_values[1])
else: else:
Expand Down

0 comments on commit 5880347

Please sign in to comment.