Completed
Pull Request — master (#2166)
by Zatreanu
01:50
created

PackageRequirement.check()   A

Complexity

Conditions 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
1
from coala_decorators.decorators import generate_eq, generate_repr
2
3
4
@generate_eq("manager", "package", "version")
5
@generate_repr()
6
class PackageRequirement:
7
    """
8
    This class helps keeping track of bear requirements. It should simply
9
    be appended to the REQUIREMENTS tuple inside the Bear class.
10
11
    Two ``PackageRequirements`` should always be equal if they have the same
12
    manager, package and version:
13
14
    >>> pr1 = PackageRequirement('pip', 'coala_decorators', '0.1.0')
15
    >>> pr2 = PackageRequirement('pip', 'coala_decorators', '0.1.0')
16
    >>> pr1 == pr2
17
    True
18
    """
19
20
    def __init__(self, manager: str, package: str, version=""):
21
        """
22
        Constructs a new PackageRequirement.
23
24
        :param manager: A string with the name of the manager (pip, npm, etc).
25
        :param package: A string with the name of the package to be installed.
26
        :param version: A number that contains the version. Leave empty to
27
                        install the latest.
28
        """
29
        self.manager = manager
30
        self.package = package
31
        self.version = version
32
33
    def check(self):
34
        """
35
        Check if the requirement is satisfied.
36
37
        >>> PackageRequirement('pip', 'coala_decorators', '0.2.1').check()
38
        Traceback (most recent call last):
39
        ...
40
        NotImplementedError
41
42
        :return: Returns True if satisfied, False if not.
43
        """
44
        raise NotImplementedError
45