Skip to content

Commit 6455437

Browse files
committed
set cc:licenseClass: improve syntax and reduce delta from legacy rdf
1 parent 2638e71 commit 6455437

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

legal_tools/rdf_generator.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Standard library
2+
import os.path
23
from urllib.parse import urlparse, urlunparse
34

45
# Third-party
@@ -80,25 +81,21 @@ def generate_rdf_file(
8081
g.set((license_uri, OWL.sameAs, URIRef(tool_obj.base_url)))
8182

8283
# set cc:licenseClass
84+
# (trailing "" creates a trailing slash to match legacy rdf)
85+
license_class_uriref = convert_https_to_http(tool_obj.creator_url)
8386
if tool_obj.category == "publicdomain":
84-
license_class_uriref = URIRef(
85-
convert_https_to_http(
86-
f"{tool_obj.creator_url}/choose/{tool_obj.unit}/"
87-
)
87+
license_class_uriref = os.path.join(
88+
license_class_uriref, "choose", "publicdomain", ""
8889
)
8990
elif tool_obj.unit in ["sampling", "sampling+"]:
90-
license_class_uriref = URIRef(
91-
convert_https_to_http(
92-
f"{tool_obj.creator_url}/{tool_obj.category}/sampling/"
93-
)
91+
license_class_uriref = os.path.join(
92+
license_class_uriref, "license", "sampling", ""
9493
)
9594
else:
96-
license_class_uriref = URIRef(
97-
convert_https_to_http(
98-
f"{tool_obj.creator_url}/{tool_obj.category}/"
99-
)
95+
license_class_uriref = os.path.join(
96+
license_class_uriref, "license", ""
10097
)
101-
g.set((license_uri, CC.licenseClass, license_class_uriref))
98+
g.set((license_uri, CC.licenseClass, URIRef(license_class_uriref)))
10299

103100
# cc:jurisdiction, if applicable
104101
# foaf:logo
@@ -109,8 +106,12 @@ def generate_rdf_file(
109106
)
110107
jurisdiction_uri = URIRef(
111108
convert_https_to_http(
112-
f"{tool_obj.creator_url}/international/"
113-
f"{tool_obj.jurisdiction_code}"
109+
os.path.join(
110+
tool_obj.creator_url,
111+
"international",
112+
tool_obj.jurisdiction_code,
113+
"", # legacy rdf has a trailing slash
114+
)
114115
)
115116
)
116117
g.add((license_uri, CC.jurisdiction, jurisdiction_uri))

0 commit comments

Comments
 (0)