-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathlicenses.py
62 lines (49 loc) · 1.35 KB
/
licenses.py
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
import json
import pkgutil
from collections import namedtuple
""" License Constants """
# IMPORTANT: Keep these constants in sync with licenselookup.json
CC_BY = "CC BY"
CC_BY_SA = "CC BY-SA"
CC_BY_ND = "CC BY-ND"
CC_BY_NC = "CC BY-NC"
CC_BY_NC_SA = "CC BY-NC-SA"
CC_BY_NC_ND = "CC BY-NC-ND"
ALL_RIGHTS_RESERVED = "All Rights Reserved"
PUBLIC_DOMAIN = "Public Domain"
SPECIAL_PERMISSIONS = "Special Permissions"
choices = (
(CC_BY, "CC BY"),
(CC_BY_SA, "CC BY-SA"),
(CC_BY_ND, "CC BY-ND"),
(CC_BY_NC, "CC BY-NC"),
(CC_BY_NC_SA, "CC BY-NC-SA"),
(CC_BY_NC_ND, "CC BY-NC-ND"),
(ALL_RIGHTS_RESERVED, "All Rights Reserved"),
(PUBLIC_DOMAIN, "Public Domain"),
(SPECIAL_PERMISSIONS, "Special Permissions"),
)
class License(
namedtuple(
"License",
[
"id",
"name",
"exists",
"url",
"description",
"custom",
"copyright_holder_required",
],
)
):
pass
def generate_list(constantlist):
for id, lang in constantlist.items():
yield License(id=int(id), description="", **lang)
def _initialize_license_list():
constantlist = json.loads(
pkgutil.get_data("le_utils", "resources/licenselookup.json").decode("utf-8")
)
return generate_list(constantlist)
LICENSELIST = list(_initialize_license_list())