| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | from coala_decorators.decorators import generate_eq, generate_repr |
||
| 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 |