GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RotateFilter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 8 3
A apply() 0 14 2
1
"""
2
This module implement a Rotate filter.
3
"""
4
from PIL import Image
5
from .interface import ImagineFilterInterface
6
7
8
class RotateFilter(ImagineFilterInterface):
9
    """
10
    Rotate filter
11
    """
12
    angle = None
13
14
    def __init__(self, **kwargs):
15
        """
16
        :param kwargs: dict
17
        """
18
        if 'angle' in kwargs and isinstance(kwargs['angle'], (int, float)):
19
            self.angle = kwargs.get('angle', 0)
20
        else:
21
            raise ValueError('Unsupported angle format or angle doesn\'t set')
22
23
    def apply(self, resource):
24
        """
25
        Apply filter to resource
26
        :param resource: Image
27
        :return: Image
28
        """
29
        if not isinstance(resource, Image.Image):
30
            raise ValueError('Unknown resource format')
31
32
        resource_format = resource.format
33
        resource = resource.rotate(self.angle, expand=True)
34
        resource.format = resource_format
35
36
        return resource
37