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
    """
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
    You can check whether the requirements are fulfilled using the check
12
    method:
13
14
    >>> PR = PackageRequirement('pip', 'coala_decorators', '0.2.1')
15
    >>> PR.check()
16
    Traceback (most recent call last):
17
    ...
18
    NotImplementedError
19
    """
20
21
    def __init__(self, manager: str, package: str, version=""):
22
        """
23
        Constructs a new PackageRequirement.
24
25
        :param manager: A string with the name of the manager (pip, npm, etc).
26
        :param package: A string with the name of the package to be installed.
27
        :param version: A number that contains the version. Leave empty to
28
                        install the latest.
29
        """
30
        self.manager = manager
31
        self.package = package
32
        self.version = version
33
34
    def check(self):
35
        """
36
        Check if the requirement is satisfied.
37
        :return: Returns True if satisfied, False if not.
38
        """
39
        raise NotImplementedError
40