@@ -78,56 +78,56 @@ def n_cyber_object_to_node(graph):
78
78
:param graph: rdflib graph object for adding nodes to
79
79
:return: The four nodes for each fo the other functions to fill
80
80
"""
81
- cyber_object_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "observableobject-" ))
82
- n_raster_facets = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "rasterpicture-" ))
83
- n_file_facets = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "filefacet-" ))
84
- n_content_facets = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "contentfacet-" ))
85
- n_exif_facets = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "exiffacet-" ))
81
+ cyber_object = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "observableobject-" ))
82
+ n_raster_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "rasterpicture-" ))
83
+ n_file_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "filefacet-" ))
84
+ n_content_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "contentfacet-" ))
85
+ n_exif_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "exiffacet-" ))
86
86
graph .add ((
87
- cyber_object_facet ,
87
+ cyber_object ,
88
88
NS_RDF .type ,
89
89
NS_UCO_OBSERVABLE .ObservableObject
90
90
))
91
91
graph .add ((
92
- cyber_object_facet ,
92
+ cyber_object ,
93
93
NS_UCO_OBSERVABLE .hasChanged ,
94
94
rdflib .Literal (False )
95
95
))
96
96
graph .add ((
97
- cyber_object_facet ,
97
+ cyber_object ,
98
98
NS_UCO_CORE .hasFacet ,
99
- n_exif_facets
99
+ n_exif_facet
100
100
))
101
101
graph .add ((
102
- cyber_object_facet ,
102
+ cyber_object ,
103
103
NS_UCO_CORE .hasFacet ,
104
- n_raster_facets
104
+ n_raster_facet
105
105
))
106
106
graph .add ((
107
- cyber_object_facet ,
107
+ cyber_object ,
108
108
NS_UCO_CORE .hasFacet ,
109
- n_file_facets
109
+ n_file_facet
110
110
))
111
- return n_exif_facets , n_raster_facets , n_file_facets , n_content_facets
111
+ return n_exif_facet , n_raster_facet , n_file_facet , n_content_facet
112
112
113
113
114
- def filecontent_object_to_node (graph , n_content_facets , file_information ):
114
+ def filecontent_object_to_node (graph , n_content_facet , file_information ):
115
115
"""
116
116
Unused: Create a node that will add the file content facet node to the graph
117
117
:param graph: rdflib graph object for adding nodes to
118
- :param n_content_facets : Blank node to contain all content facet information
118
+ :param n_content_facet : Blank node to contain all content facet information
119
119
:param file_information: Dictionary containing information about file being analysed
120
120
:return: None
121
121
"""
122
122
byte_order_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "byteorder-" ))
123
123
file_hash_facet = rdflib .URIRef (get_node_iri (ns = ns_kb , prefix = "hash-" ))
124
124
graph .add ((
125
- n_content_facets ,
125
+ n_content_facet ,
126
126
NS_RDF .type ,
127
127
NS_UCO_OBSERVABLE .ContentDataFacet
128
128
))
129
129
graph .add ((
130
- n_content_facets ,
130
+ n_content_facet ,
131
131
NS_UCO_OBSERVABLE .byteOrder ,
132
132
byte_order_facet
133
133
))
@@ -143,19 +143,19 @@ def filecontent_object_to_node(graph, n_content_facets, file_information):
143
143
))
144
144
if 'mimetype' in file_information .keys ():
145
145
graph .add ((
146
- n_content_facets ,
146
+ n_content_facet ,
147
147
NS_UCO_OBSERVABLE .mimeType ,
148
148
rdflib .Literal (file_information ["mimetype" ])
149
149
))
150
150
if 'size' in file_information .keys ():
151
151
graph .add ((
152
- n_content_facets ,
152
+ n_content_facet ,
153
153
NS_UCO_OBSERVABLE .sizeInBytes ,
154
154
rdflib .term .Literal (file_information ["size" ],
155
155
datatype = NS_XSD .integer )
156
156
))
157
157
graph .add ((
158
- n_content_facets ,
158
+ n_content_facet ,
159
159
NS_UCO_OBSERVABLE .hash ,
160
160
file_hash_facet
161
161
))
@@ -166,90 +166,90 @@ def filecontent_object_to_node(graph, n_content_facets, file_information):
166
166
))
167
167
168
168
169
- def filefacets_object_to_node (graph , n_file_facets , file_information ):
169
+ def filefacets_object_to_node (graph , n_file_facet , file_information ):
170
170
"""
171
171
Adding file facet object to the graph object
172
172
:param graph: rdflib graph object for adding nodes to
173
- :param n_file_facets : file facet node to add facets of file to
173
+ :param n_file_facet : file facet node to add facets of file to
174
174
:param file_information: Dictionary containing information about file being analysed
175
175
:return: None
176
176
"""
177
177
file_name , ext = os .path .splitext (file_information ['Filename' ])
178
178
file_ext = ext [1 :]
179
179
graph .add ((
180
- n_file_facets ,
180
+ n_file_facet ,
181
181
NS_RDF .type ,
182
182
NS_UCO_OBSERVABLE .FileFacet
183
183
))
184
184
graph .add ((
185
- n_file_facets ,
185
+ n_file_facet ,
186
186
NS_UCO_OBSERVABLE .fileName ,
187
187
rdflib .Literal (os .path .basename (file_information ["Filename" ]))
188
188
))
189
189
graph .add ((
190
- n_file_facets ,
190
+ n_file_facet ,
191
191
NS_UCO_OBSERVABLE .filePath ,
192
192
rdflib .Literal (os .path .abspath (file_information ["Filename" ]))
193
193
))
194
194
graph .add ((
195
- n_file_facets ,
195
+ n_file_facet ,
196
196
NS_UCO_OBSERVABLE .extension ,
197
197
rdflib .Literal (file_ext )
198
198
))
199
199
if 'size' in file_information .keys ():
200
200
graph .add ((
201
- n_file_facets ,
201
+ n_file_facet ,
202
202
NS_UCO_OBSERVABLE .sizeInBytes ,
203
203
rdflib .term .Literal (file_information ["size" ],
204
204
datatype = NS_XSD .integer )
205
205
))
206
206
207
207
208
- def raster_object_to_node (graph , controlled_dict , n_raster_facets , file_information ):
208
+ def raster_object_to_node (graph , controlled_dict , n_raster_facet , file_information ):
209
209
"""
210
210
Adding file's raster facet objects to the graph object
211
211
:param graph: rdflib graph object for adding nodes to
212
212
:param controlled_dict: Dictionary containing the EXIF information from image
213
- :param n_raster_facets : raster facet node to add raster facets of file to
213
+ :param n_raster_facet : raster facet node to add raster facets of file to
214
214
:param file_information: Dictionary containing information about file being analysed
215
215
:return: None
216
216
"""
217
217
file_name , ext = os .path .splitext (file_information ['Filename' ])
218
218
file_ext = ext [1 :]
219
219
graph .add ((
220
- n_raster_facets ,
220
+ n_raster_facet ,
221
221
NS_RDF .type ,
222
222
NS_UCO_OBSERVABLE .RasterPictureFacet
223
223
))
224
224
graph .add ((
225
- n_raster_facets ,
225
+ n_raster_facet ,
226
226
NS_UCO_OBSERVABLE .pictureType ,
227
227
rdflib .Literal (file_ext )
228
228
))
229
229
# :TODO The below feels a bit hacky probably a better way to do it
230
230
if 'EXIF ExifImageLength' in controlled_dict .keys ():
231
231
graph .add ((
232
- n_raster_facets ,
232
+ n_raster_facet ,
233
233
NS_UCO_OBSERVABLE .pictureHeight ,
234
234
rdflib .term .Literal (int (float (str (controlled_dict ['EXIF ExifImageLength' ]))),
235
235
datatype = NS_XSD .integer )
236
236
))
237
237
if 'EXIF ExifImageWidth' in controlled_dict .keys ():
238
238
graph .add ((
239
- n_raster_facets ,
239
+ n_raster_facet ,
240
240
NS_UCO_OBSERVABLE .pictureWidth ,
241
241
rdflib .term .Literal (int (float (str (controlled_dict ['EXIF ExifImageWidth' ]))),
242
242
datatype = NS_XSD .integer )
243
243
))
244
244
if 'EXIF CompressedBitsPerPixel' in controlled_dict .keys ():
245
245
graph .add ((
246
- n_raster_facets ,
246
+ n_raster_facet ,
247
247
NS_UCO_OBSERVABLE .bitsPerPixel ,
248
248
rdflib .term .Literal (int (float (str (controlled_dict ['EXIF CompressedBitsPerPixel' ]))),
249
249
datatype = NS_XSD .integer )
250
250
))
251
251
graph .add ((
252
- n_raster_facets ,
252
+ n_raster_facet ,
253
253
NS_RDFS .comment ,
254
254
rdflib .Literal ("Information represented here from exif information not from "
255
255
"file system stats except for extension, which uses os python lib" )
@@ -327,11 +327,11 @@ def main():
327
327
tag_dict = create_exif_dict (tags )
328
328
case_utils .local_uuid .configure ()
329
329
out_graph = rdflib .Graph ()
330
- exif_facet_node , raster_facets_node , file_facets_node , content_facets \
330
+ exif_facet_node , raster_facet_node , file_facet_node , content_facet_node \
331
331
= n_cyber_object_to_node (out_graph )
332
332
controlled_dictionary_object_to_node (out_graph , tag_dict , exif_facet_node )
333
- filefacets_object_to_node (out_graph , file_facets_node , file_info )
334
- raster_object_to_node (out_graph , tag_dict , raster_facets_node , file_info )
333
+ filefacets_object_to_node (out_graph , file_facet_node , file_info )
334
+ raster_object_to_node (out_graph , tag_dict , raster_facet_node , file_info )
335
335
336
336
context = {"kb" : "http://example.org/kb/" ,
337
337
"rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ,
0 commit comments