# Path: testsuite/cases/base.py
# def rpartial(func, *args, **keywords):
#     """
#     right partial — same as functools.partial, but pass function args first
#     """
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(fargs + args), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def root(*chunks):
#     return os.path.abspath(os.path.join(
#         os.path.dirname(__file__), '..', *chunks))
# 
# class FullCycleBaseCase(BaseTestCase):
#     def handle_args(self, level, name, filename, filetype):
#         self.level = level
#         self.name = name
#         self.filename = filename
#         self.filetype = filetype
# 
#     def create_test_data(self):
#         return ()
# 
#     def readable_args(self):
#         return [self.name]
# 
# Path: testsuite/cases/pillow.py
# class PillowTestCase(BaseTestCase):
#     def create_test_data(self):
#     def resize(cls, self, size, resample=Image.NEAREST):
#     def gaussian_blur(cls, self, radius, n=3):
#     def getchannel(cls, self, channel):
#         L = math.sqrt(12.0 * float(radius) * radius / n + 1.0)


from io import BytesIO
from .base import rpartial, root, FullCycleBaseCase
from .pillow import Image, PillowTestCase



class FullCycleCase(FullCycleBaseCase, PillowTestCase):
    def runner(self):
        im = Image.open(root('resources', self.filename))

        if self.level > 0:
            im = im.transpose(Image.ROTATE_270)

        if self.level > 1:
            size = (int(im.size[0] * 0.4 + 0.5),
                    int(im.size[1] * 0.4 + 0.5))
            im = self.resize(im, size, Image.BICUBIC)

        if self.level > 2:
            im = self.gaussian_blur(im, 4)

        im.save(BytesIO(), format=self.filetype, quality=85)
        # im.save('../_out.{}.pillow.png'.format(self.level))


cases = [

# Path: testsuite/cases/base.py
# def rpartial(func, *args, **keywords):
#     """
#     right partial — same as functools.partial, but pass function args first
#     """
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(fargs + args), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def root(*chunks):
#     return os.path.abspath(os.path.join(
#         os.path.dirname(__file__), '..', *chunks))
# 
# class FullCycleBaseCase(BaseTestCase):
#     def handle_args(self, level, name, filename, filetype):
#         self.level = level
#         self.name = name
#         self.filename = filename
#         self.filetype = filetype
# 
#     def create_test_data(self):
#         return ()
# 
#     def readable_args(self):
#         return [self.name]
# 
# Path: testsuite/cases/pillow.py
# class PillowTestCase(BaseTestCase):
#     def create_test_data(self):
#     def resize(cls, self, size, resample=Image.NEAREST):
#     def gaussian_blur(cls, self, radius, n=3):
#     def getchannel(cls, self, channel):
#         L = math.sqrt(12.0 * float(radius) * radius / n + 1.0)


# Path: testsuite/cases/pillow_full_cycle.py
from io import BytesIO
from .base import rpartial, root, FullCycleBaseCase
from .pillow import Image, PillowTestCase




class FullCycleCase(FullCycleBaseCase, PillowTestCase):
    def runner(self):
        im = Image.open(root('resources', self.filename))

        if self.level > 0:
            im = im.transpose(Image.ROTATE_270)

        if self.level > 1:
            size = (int(im.size[0] * 0.4 + 0.5),
                    int(im.size[1] * 0.4 + 0.5))
            im = self.resize(im, size, Image.BICUBIC)

        if self.level > 2:
            im = self.gaussian_blur(im, 4)

        im.save(BytesIO(), format=self.filetype, quality=85)
        # im.save('../_out.{}.pillow.png'.format(self.level))


cases = [

    rpartial(FullCycleCase, 0, 'Load+save', 'pineapple.jpeg', 'JPEG'),