@@ -31,7 +31,6 @@ def generate_rdf_file(
31
31
# Retrieving license data from the database based on the arguments.
32
32
if generate_all_licenses is True :
33
33
retrieved_tools = Tool .objects .all ()
34
-
35
34
else :
36
35
if jurisdiction :
37
36
retrieved_tool = Tool .objects .filter (
@@ -65,19 +64,13 @@ def generate_rdf_file(
65
64
license_uri = URIRef (convert_https_to_http (tool_obj .base_url ))
66
65
67
66
g .set ((license_uri , RDF .type , CC .License ))
67
+
68
68
g .add ((license_uri , DCTERMS .identifier , Literal (f"{ tool_obj .unit } " )))
69
- g .add (
70
- (license_uri , DCTERMS .hasVersion , Literal (f"{ tool_obj .version } " ))
71
- )
69
+ version = Literal (f"{ tool_obj .version } " )
70
+ g .add ((license_uri , DCTERMS .hasVersion , version ))
72
71
g .add ((license_uri , OWL .sameAs , URIRef (tool_obj .base_url )))
73
-
74
- g .add (
75
- (
76
- license_uri ,
77
- DCTERMS .creator ,
78
- URIRef (convert_https_to_http (tool_obj .creator_url )),
79
- )
80
- )
72
+ creator = URIRef (convert_https_to_http (tool_obj .creator_url ))
73
+ g .add ((license_uri , DCTERMS .creator , creator ))
81
74
82
75
# adding cc:licenseClass
83
76
if tool_obj .category == "publicdomain" :
@@ -86,50 +79,32 @@ def generate_rdf_file(
86
79
f"{ tool_obj .creator_url } /choose/{ tool_obj .unit } /"
87
80
)
88
81
)
89
-
90
82
elif tool_obj .unit in ["sampling" , "sampling+" ]:
91
83
license_class_uriref = URIRef (
92
84
convert_https_to_http (
93
85
f"{ tool_obj .creator_url } /{ tool_obj .category } /sampling/"
94
86
)
95
87
)
96
-
97
88
else :
98
89
license_class_uriref = URIRef (
99
90
convert_https_to_http (
100
91
f"{ tool_obj .creator_url } /{ tool_obj .category } /"
101
92
)
102
93
)
103
-
104
94
g .add ((license_uri , CC .licenseClass , license_class_uriref ))
105
95
106
- # g.add(
107
- # (
108
- # license_uri,
109
- # DCT.description,
110
- # Literal(" NEED SUGGESTIONS ON WHAT TO PUT HERE."),
111
- # )
112
- # )
113
-
114
96
if tool_obj .jurisdiction_code :
115
97
logo_prefix = (
116
98
f"{ FOAF_LOGO_URL } { tool_obj .unit } "
117
99
f"/{ tool_obj .version } /{ tool_obj .jurisdiction_code } "
118
100
)
119
-
120
- g .add (
121
- (
122
- license_uri ,
123
- CC .jurisdiction ,
124
- URIRef (
125
- convert_https_to_http (
126
- f"{ tool_obj .creator_url } /international/"
127
- f"{ tool_obj .jurisdiction_code } "
128
- )
129
- ),
101
+ jurisdiction_uri = URIRef (
102
+ convert_https_to_http (
103
+ f"{ tool_obj .creator_url } /international/"
104
+ f"{ tool_obj .jurisdiction_code } "
130
105
)
131
106
)
132
-
107
+ g . add (( license_uri , CC . jurisdiction , jurisdiction_uri ))
133
108
else :
134
109
logo_prefix = f"{ FOAF_LOGO_URL } { tool_obj .unit } /{ tool_obj .version } "
135
110
@@ -151,53 +126,34 @@ def generate_rdf_file(
151
126
g .add ((license_uri , DCTERMS .title , (tool_title_data )))
152
127
153
128
legal_code_url = legal_code_object .legal_code_url
154
- g .add (
155
- (
156
- license_uri ,
157
- CC .legalcode ,
158
- URIRef (
159
- convert_https_to_http (
160
- f"{ tool_obj .creator_url } { legal_code_url } "
161
- )
162
- ),
129
+ cc_legal_code = URIRef (
130
+ convert_https_to_http (
131
+ f"{ tool_obj .creator_url } { legal_code_url } "
163
132
)
164
133
)
134
+ g .add ((license_uri , CC .legalcode , cc_legal_code ))
135
+
165
136
# added DCTERMS.language for every legal_code_url
166
137
if not generate_all_licenses :
167
138
g .add (
168
139
(CC [legal_code_url ], DCTERMS .language , Literal (tool_lang ))
169
140
)
170
141
171
142
if tool_obj .deprecated_on :
172
- g .add (
173
- (
174
- license_uri ,
175
- CC .deprecatedOn ,
176
- Literal (tool_obj .deprecated_on , datatype = XSD .date ),
177
- )
178
- )
143
+ deprecated_on = Literal (tool_obj .deprecated_on , datatype = XSD .date )
144
+ g .add ((license_uri , CC .deprecatedOn , deprecated_on ))
179
145
180
146
if tool_obj .is_replaced_by :
181
- g .add (
182
- (
183
- license_uri ,
184
- DCTERMS .isReplacedBy ,
185
- URIRef (
186
- convert_https_to_http (tool_obj .is_replaced_by .base_url )
187
- ),
188
- )
147
+ replaced_by = URIRef (
148
+ convert_https_to_http (tool_obj .is_replaced_by .base_url )
189
149
)
150
+ g .add ((license_uri , DCTERMS .isReplacedBy , replaced_by ))
190
151
191
152
if tool_obj .is_based_on :
192
- g .add (
193
- (
194
- license_uri ,
195
- DCTERMS .source ,
196
- URIRef (
197
- convert_https_to_http (tool_obj .is_based_on .base_url )
198
- ),
199
- )
153
+ based_on = URIRef (
154
+ convert_https_to_http (tool_obj .is_based_on .base_url )
200
155
)
156
+ g .add ((license_uri , DCTERMS .source , based_on ))
201
157
202
158
# Adding properties
203
159
# Permits
0 commit comments