@@ -66,36 +66,10 @@ def generate_rdf_file(
66
66
67
67
g .set ((license_uri , RDF .type , CC .License ))
68
68
69
- # set dcterms:creator
70
- creator = URIRef (convert_https_to_http (tool_obj .creator_url ))
71
- g .set ((license_uri , DCTERMS .creator , creator ))
72
-
73
- # set dcterms:hasVersion
74
- version = Literal (f"{ tool_obj .version } " )
75
- g .set ((license_uri , DCTERMS .hasVersion , version ))
76
-
77
- # set dcterms:identifier
78
- g .set ((license_uri , DCTERMS .identifier , Literal (f"{ tool_obj .unit } " )))
79
-
80
- # set owl:sameAs (alias HTTPS)
81
- g .set ((license_uri , OWL .sameAs , URIRef (tool_obj .base_url )))
82
-
83
- # 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 )
86
- if tool_obj .category == "publicdomain" :
87
- license_class_uriref = os .path .join (
88
- license_class_uriref , "choose" , "publicdomain" , ""
89
- )
90
- elif "sampling" in tool_obj .unit :
91
- license_class_uriref = os .path .join (
92
- license_class_uriref , "license" , "sampling" , ""
93
- )
94
- else :
95
- license_class_uriref = os .path .join (
96
- license_class_uriref , "license" , ""
97
- )
98
- g .set ((license_uri , CC .licenseClass , URIRef (license_class_uriref )))
69
+ # set cc:deprecatedOn, if applicable
70
+ if tool_obj .deprecated_on :
71
+ deprecated_on = Literal (tool_obj .deprecated_on , datatype = XSD .date )
72
+ g .set ((license_uri , CC .deprecatedOn , deprecated_on ))
99
73
100
74
# cc:jurisdiction, if applicable
101
75
# foaf:logo
@@ -137,7 +111,7 @@ def generate_rdf_file(
137
111
g .add ((license_uri , DCTERMS .title , (tool_title_data )))
138
112
139
113
legal_code_url = legal_code_object .legal_code_url .replace (
140
- f".{ tool_lang } " , ""
114
+ f".{ tool_lang } " , ""
141
115
)
142
116
cc_legal_code = URIRef (
143
117
convert_https_to_http (
@@ -152,26 +126,22 @@ def generate_rdf_file(
152
126
(CC [legal_code_url ], DCTERMS .language , Literal (tool_lang ))
153
127
)
154
128
155
- # set cc:depredatedOn, if applicable
156
- if tool_obj .deprecated_on :
157
- deprecated_on = Literal (tool_obj .deprecated_on , datatype = XSD .date )
158
- g .set ((license_uri , CC .deprecatedOn , deprecated_on ))
159
-
160
- # set dcterms:isReplacedBy, if applicable
161
- if tool_obj .is_replaced_by :
162
- # Convert to Literal so that the URL string is stored instead of
163
- # the object referenced
164
- replaced_by = Literal (
165
- URIRef (convert_https_to_http (tool_obj .is_replaced_by .base_url ))
129
+ # set cc:licenseClass
130
+ # (trailing "" creates a trailing slash to match legacy rdf)
131
+ license_class_uriref = convert_https_to_http (tool_obj .creator_url )
132
+ if tool_obj .category == "publicdomain" :
133
+ license_class_uriref = os .path .join (
134
+ license_class_uriref , "choose" , "publicdomain" , ""
166
135
)
167
- g .set ((license_uri , DCTERMS .isReplacedBy , replaced_by ))
168
-
169
- # set dcterms:source, if applicable
170
- if tool_obj .is_based_on :
171
- based_on = URIRef (
172
- convert_https_to_http (tool_obj .is_based_on .base_url )
136
+ elif "sampling" in tool_obj .unit :
137
+ license_class_uriref = os .path .join (
138
+ license_class_uriref , "license" , "sampling" , ""
173
139
)
174
- g .set ((license_uri , DCTERMS .source , based_on ))
140
+ else :
141
+ license_class_uriref = os .path .join (
142
+ license_class_uriref , "license" , ""
143
+ )
144
+ g .set ((license_uri , CC .licenseClass , URIRef (license_class_uriref )))
175
145
176
146
# add cc:permits, as applicable
177
147
if tool_obj .permits_derivative_works :
@@ -183,6 +153,12 @@ def generate_rdf_file(
183
153
if tool_obj .permits_sharing :
184
154
g .add ((license_uri , CC .permits , CC .Sharing ))
185
155
156
+ # add cc:prohibits, as applicable
157
+ if tool_obj .prohibits_commercial_use :
158
+ g .add ((license_uri , CC .prohibits , CC .CommercialUse ))
159
+ if tool_obj .prohibits_high_income_nation_use :
160
+ g .add ((license_uri , CC .prohibits , CC .HighIncomeNationUse ))
161
+
186
162
# add cc:requires, as applicable
187
163
if tool_obj .requires_attribution :
188
164
g .add ((license_uri , CC .requires , CC .Attribution ))
@@ -193,11 +169,35 @@ def generate_rdf_file(
193
169
if tool_obj .requires_source_code :
194
170
g .add ((license_uri , CC .requires , CC .SourceCode ))
195
171
196
- # add cc:prohibits, as applicable
197
- if tool_obj .prohibits_commercial_use :
198
- g .add ((license_uri , CC .prohibits , CC .CommercialUse ))
199
- if tool_obj .prohibits_high_income_nation_use :
200
- g .add ((license_uri , CC .prohibits , CC .HighIncomeNationUse ))
172
+ # set dcterms:creator
173
+ creator = URIRef (convert_https_to_http (tool_obj .creator_url ))
174
+ g .set ((license_uri , DCTERMS .creator , creator ))
175
+
176
+ # set dcterms:hasVersion
177
+ version = Literal (f"{ tool_obj .version } " )
178
+ g .set ((license_uri , DCTERMS .hasVersion , version ))
179
+
180
+ # set dcterms:identifier
181
+ g .set ((license_uri , DCTERMS .identifier , Literal (f"{ tool_obj .unit } " )))
182
+
183
+ # set dcterms:isReplacedBy, if applicable
184
+ if tool_obj .is_replaced_by :
185
+ # Convert to Literal so that the URL string is stored instead of
186
+ # the object referenced
187
+ replaced_by = Literal (
188
+ URIRef (convert_https_to_http (tool_obj .is_replaced_by .base_url ))
189
+ )
190
+ g .set ((license_uri , DCTERMS .isReplacedBy , replaced_by ))
191
+
192
+ # set dcterms:source, if applicable
193
+ if tool_obj .is_based_on :
194
+ based_on = URIRef (
195
+ convert_https_to_http (tool_obj .is_based_on .base_url )
196
+ )
197
+ g .set ((license_uri , DCTERMS .source , based_on ))
198
+
199
+ # set owl:sameAs (alias HTTPS)
200
+ g .set ((license_uri , OWL .sameAs , URIRef (tool_obj .base_url )))
201
201
202
202
return g
203
203
0 commit comments