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

PackageRequirement.__init__()   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_repr
2
3
4
@generate_repr()
5
class PackageRequirement:
6
    """
7
    This class helps keeping track of bear requirements. It should simply
8
    be appended to the REQUIREMENTS tuple inside the Bear class.
9
10
    You can check whether the requirements are fulfilled using the check
11
    method:
12
13
    >>> PR = PackageRequirement('pip', 'coala_decorators', '0.2.1')
14
    >>> PR.check()
15
    Traceback (most recent call last):
16
    ...
17
    NotImplementedError
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
        :return: Returns True if satisfied, False if not.
38
        """
39
        raise NotImplementedError
40