-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdependency.py
More file actions
63 lines (50 loc) · 1.53 KB
/
dependency.py
File metadata and controls
63 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from dataclasses import dataclass
from packaging.requirements import Requirement
@dataclass
class License:
name: str
url: str
@dataclass
class Dependency:
requirement: Requirement
description: str
_license: License
oss_link: str
package_link: str
@property
def name(self) -> str:
return self.requirement.name
@property
def version(self) -> str:
return self.requirement.specifier.__str__().strip()
def build_description(self) -> str:
return f"""{self.description}
License: [{self._license.name}]({self._license.url}) ✅ \
[Open Source]({self.oss_link}) ✅ \
[More facts]({self.package_link})
"""
def __hash__(self):
return hash(self.requirement)
DefusedXML = Dependency(
Requirement("defusedxml~=0.7.1"),
description="""\
This package is [recommended by the Python community](https://docs.python.org/3/library/xml.html#the-defusedxml-package) \
to protect against XML vulnerabilities.\
""",
_license=License(
"PSF-2.0",
"https://opensource.org/license/python-2-0/",
),
oss_link="https://github.com/tiran/defusedxml",
package_link="https://pypi.org/project/defusedxml/",
)
Security = Dependency(
Requirement("security~=1.2.0"),
description="""This library holds security tools for protecting Python API calls.""",
_license=License(
"MIT",
"https://opensource.org/license/MIT/",
),
oss_link="https://github.com/pixee/python-security",
package_link="https://pypi.org/project/security/",
)