Coverage for app / services / system_resources / licences.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-10-31 11:21 +0000
1"""
2The licences built-in knowledge from other publishers is used under, and the
3credit each asks for.
5One registry for every built-in website source — News's feeds today — so a
6licence is defined once and every source using it carries the same credit.
7``tests/test_builtin_knowledge.py`` holds every licence to permitting
8commercial reuse: CHAIN-R is a commercial product, and a non-commercial
9licence is no licence for it.
10"""
12from __future__ import annotations
14from dataclasses import dataclass
17@dataclass(frozen=True)
18class Licence:
19 """A licence a built-in source is used under, and what it asks in return."""
21 key: str
22 name: str
23 url: str
24 #: The credit every passage carries; ``{publisher}`` is filled per source.
25 attribution: str
26 #: Whether commercial reuse is permitted. Every licence used here must
27 #: say yes: CHAIN-R is a commercial product.
28 commercial_use: bool
29 #: What else the licence asks, in a sentence.
30 conditions: str
32 def credit(self, publisher: str) -> str:
33 return self.attribution.format(publisher=publisher)
36LICENCES: dict[str, Licence] = {
37 licence.key: licence
38 for licence in (
39 Licence(
40 key="ogl-3.0",
41 name="Open Government Licence v3.0",
42 url="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/",
43 attribution=(
44 "Contains public sector information licensed under the Open "
45 "Government Licence v3.0."
46 ),
47 commercial_use=True,
48 conditions=(
49 "Acknowledge the source; do not imply official status or "
50 "endorsement, or mislead about the information."
51 ),
52 ),
53 Licence(
54 key="cc-by-4.0",
55 name="Creative Commons Attribution 4.0 International",
56 url="https://creativecommons.org/licenses/by/4.0/",
57 attribution=(
58 "Source: {publisher}, licensed under CC BY 4.0. Passages are "
59 "excerpts of the linked original."
60 ),
61 commercial_use=True,
62 conditions="Credit the source, link the licence and say if it was changed.",
63 ),
64 Licence(
65 key="cc-by-3.0",
66 name="Creative Commons Attribution 3.0 Unported",
67 url="https://creativecommons.org/licenses/by/3.0/",
68 attribution=(
69 "Originally published by {publisher}, licensed under CC BY 3.0. "
70 "Passages are excerpts of the linked original."
71 ),
72 commercial_use=True,
73 conditions=(
74 "Credit the author and the source, link the licence and say if "
75 "it was changed."
76 ),
77 ),
78 Licence(
79 key="edpb-reuse",
80 name="EDPB reuse notice",
81 url="https://www.edpb.europa.eu/copyright_en",
82 attribution="Source: {publisher}.",
83 commercial_use=True,
84 conditions=(
85 "Acknowledge the source and do not distort the original meaning."
86 ),
87 ),
88 Licence(
89 key="us-public-domain",
90 name="Public domain (US federal government work, 17 U.S.C. § 105)",
91 url="https://www.copyright.gov/title17/92chap1.html#105",
92 attribution=(
93 "Source: {publisher}. A work of the US federal government, in "
94 "the public domain in the United States."
95 ),
96 commercial_use=True,
97 conditions=(
98 "Credit the agency, and do not imply its endorsement of any "
99 "product or service."
100 ),
101 ),
102 )
103}