
from __future__ import print_function, unicode_literals, absolute_import

from PIL import Image

from .base import rpartial
from .pillow import PillowTestCase


class RotateRightCase(PillowTestCase):
    def handle_args(self, name, transposition):
        self.name = name
        self.transposition = transposition

    def runner(self, im):
        im.transpose(self.transposition)

    def readable_args(self):
        return [self.name]


cases = [
    rpartial(RotateRightCase, 'Flop', Image.FLIP_LEFT_RIGHT),
    rpartial(RotateRightCase, 'Flip', Image.FLIP_TOP_BOTTOM),
    rpartial(RotateRightCase, 'Rotate 90', Image.ROTATE_90),
    rpartial(RotateRightCase, 'Rotate 180', Image.ROTATE_180),
    rpartial(RotateRightCase, 'Rotate 270', Image.ROTATE_270),
]

if hasattr(Image, 'TRANSPOSE'):
    cases.append(rpartial(RotateRightCase, 'Transpose', Image.TRANSPOSE))


from __future__ import print_function, unicode_literals, absolute_import

from PIL import Image

from .base import rpartial
from .pillow import PillowTestCase


class RotateRightCase(PillowTestCase):
    def handle_args(self, name, transposition):
        self.name = name
        self.transposition = transposition

    def runner(self, im):
        for trans in self.transposition:
            im = im.transpose(trans)

    def readable_args(self):
        return [self.name]


cases = [
    rpartial(RotateRightCase, 'Flop', [Image.FLIP_LEFT_RIGHT]),
    rpartial(RotateRightCase, 'Flip', [Image.FLIP_TOP_BOTTOM]),
    rpartial(RotateRightCase, 'Rotate 90', [Image.ROTATE_90]),
    rpartial(RotateRightCase, 'Rotate 180', [Image.ROTATE_180]),
    rpartial(RotateRightCase, 'Rotate 270', [Image.ROTATE_270]),
    rpartial(RotateRightCase, 'Transpose',
        [Image.TRANSPOSE]
        if hasattr(Image, 'TRANSPOSE')
        else [Image.ROTATE_90, Image.FLIP_LEFT_RIGHT]),
    rpartial(RotateRightCase, 'Transpose180',
        [Image.TRANSPOSE_ROTATE_180]
        if hasattr(Image, 'TRANSPOSE_ROTATE_180')
        else [Image.ROTATE_270, Image.FLIP_LEFT_RIGHT]),
]

Transpose and Transpose180 for all Pillow versions
Transpose and Transpose180 for all Pillow versions

  
  from __future__ import print_function, unicode_literals, absolute_import
  
  from PIL import Image
  
  from .base import rpartial
  from .pillow import PillowTestCase
  
  
  class RotateRightCase(PillowTestCase):
      def handle_args(self, name, transposition):
          self.name = name
          self.transposition = transposition
  
      def runner(self, im):
-         im.transpose(self.transposition)
+         for trans in self.transposition:
+             im = im.transpose(trans)
  
      def readable_args(self):
          return [self.name]
  
  
  cases = [
-     rpartial(RotateRightCase, 'Flop', Image.FLIP_LEFT_RIGHT),
+     rpartial(RotateRightCase, 'Flop', [Image.FLIP_LEFT_RIGHT]),
-     rpartial(RotateRightCase, 'Flip', Image.FLIP_TOP_BOTTOM),
+     rpartial(RotateRightCase, 'Flip', [Image.FLIP_TOP_BOTTOM]),
-     rpartial(RotateRightCase, 'Rotate 90', Image.ROTATE_90),
+     rpartial(RotateRightCase, 'Rotate 90', [Image.ROTATE_90]),
-     rpartial(RotateRightCase, 'Rotate 180', Image.ROTATE_180),
+     rpartial(RotateRightCase, 'Rotate 180', [Image.ROTATE_180]),
-     rpartial(RotateRightCase, 'Rotate 270', Image.ROTATE_270),
+     rpartial(RotateRightCase, 'Rotate 270', [Image.ROTATE_270]),
+     rpartial(RotateRightCase, 'Transpose',
+         [Image.TRANSPOSE]
+         if hasattr(Image, 'TRANSPOSE')
+         else [Image.ROTATE_90, Image.FLIP_LEFT_RIGHT]),
+     rpartial(RotateRightCase, 'Transpose180',
+         [Image.TRANSPOSE_ROTATE_180]
+         if hasattr(Image, 'TRANSPOSE_ROTATE_180')
+         else [Image.ROTATE_270, Image.FLIP_LEFT_RIGHT]),
  ]
  
- if hasattr(Image, 'TRANSPOSE'):
-     cases.append(rpartial(RotateRightCase, 'Transpose', Image.TRANSPOSE))
- 
Transpose and Transpose180 for all Pillow versions
## Code Before:

from __future__ import print_function, unicode_literals, absolute_import

from PIL import Image

from .base import rpartial
from .pillow import PillowTestCase


class RotateRightCase(PillowTestCase):
    def handle_args(self, name, transposition):
        self.name = name
        self.transposition = transposition

    def runner(self, im):
        im.transpose(self.transposition)

    def readable_args(self):
        return [self.name]


cases = [
    rpartial(RotateRightCase, 'Flop', Image.FLIP_LEFT_RIGHT),
    rpartial(RotateRightCase, 'Flip', Image.FLIP_TOP_BOTTOM),
    rpartial(RotateRightCase, 'Rotate 90', Image.ROTATE_90),
    rpartial(RotateRightCase, 'Rotate 180', Image.ROTATE_180),
    rpartial(RotateRightCase, 'Rotate 270', Image.ROTATE_270),
]

if hasattr(Image, 'TRANSPOSE'):
    cases.append(rpartial(RotateRightCase, 'Transpose', Image.TRANSPOSE))

## Instruction:
Transpose and Transpose180 for all Pillow versions
## Code After:

from __future__ import print_function, unicode_literals, absolute_import

from PIL import Image

from .base import rpartial
from .pillow import PillowTestCase


class RotateRightCase(PillowTestCase):
    def handle_args(self, name, transposition):
        self.name = name
        self.transposition = transposition

    def runner(self, im):
        for trans in self.transposition:
            im = im.transpose(trans)

    def readable_args(self):
        return [self.name]


cases = [
    rpartial(RotateRightCase, 'Flop', [Image.FLIP_LEFT_RIGHT]),
    rpartial(RotateRightCase, 'Flip', [Image.FLIP_TOP_BOTTOM]),
    rpartial(RotateRightCase, 'Rotate 90', [Image.ROTATE_90]),
    rpartial(RotateRightCase, 'Rotate 180', [Image.ROTATE_180]),
    rpartial(RotateRightCase, 'Rotate 270', [Image.ROTATE_270]),
    rpartial(RotateRightCase, 'Transpose',
        [Image.TRANSPOSE]
        if hasattr(Image, 'TRANSPOSE')
        else [Image.ROTATE_90, Image.FLIP_LEFT_RIGHT]),
    rpartial(RotateRightCase, 'Transpose180',
        [Image.TRANSPOSE_ROTATE_180]
        if hasattr(Image, 'TRANSPOSE_ROTATE_180')
        else [Image.ROTATE_270, Image.FLIP_LEFT_RIGHT]),
]
