Skip to content

Commit f6c72ab

Browse files
authored
Merge pull request #110 from casework/change_individuals_suffix_start
Change start of NamedIndividuals' suffices to use last path-segment of class's IRI
2 parents aeca9a4 + 30a5576 commit f6c72ab

File tree

7 files changed

+185
-185
lines changed

7 files changed

+185
-185
lines changed

case_utils/case_file/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_file_node(
7070
:param filepath: The path to the file to characterize. Can be relative or absolute.
7171
:type filepath: str
7272
73-
:param node_iri: The desired full IRI for the node. If absent, will make an IRI of the pattern ``ns_base + 'file-' + uuid4``
73+
:param node_iri: The desired full IRI for the node. If absent, will make an IRI of the pattern ``ns_base + 'File-' + uuid4``
7474
:type node_iri: str
7575
7676
:param node_prefix: The base prefix to use if node_iri is not supplied.
@@ -88,7 +88,7 @@ def create_file_node(
8888
node_namespace = rdflib.Namespace(node_prefix)
8989

9090
if node_iri is None:
91-
node_slug = "file-" + case_utils.local_uuid.local_uuid()
91+
node_slug = "File-" + case_utils.local_uuid.local_uuid()
9292
node_iri = node_namespace[node_slug]
9393
n_file = rdflib.URIRef(node_iri)
9494
graph.add((n_file, NS_RDF.type, NS_UCO_OBSERVABLE.File))
@@ -97,7 +97,7 @@ def create_file_node(
9797
literal_basename = rdflib.Literal(basename)
9898

9999
file_stat = os.stat(filepath)
100-
n_file_facet = node_namespace["file-facet-" + case_utils.local_uuid.local_uuid()]
100+
n_file_facet = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()]
101101
graph.add(
102102
(
103103
n_file_facet,
@@ -273,7 +273,7 @@ def main() -> None:
273273
context_dictionary = {k: v for (k, v) in graph.namespace_manager.namespaces()}
274274
serialize_kwargs["context"] = context_dictionary
275275

276-
node_iri = NS_BASE["file-" + case_utils.local_uuid.local_uuid()]
276+
node_iri = NS_BASE["File-" + case_utils.local_uuid.local_uuid()]
277277
create_file_node(
278278
graph,
279279
args.in_file,

tests/case_utils/case_file/kb.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,26 @@
99
},
1010
"@graph": [
1111
{
12-
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169",
13-
"@type": "uco-observable:ContentDataFacet",
14-
"uco-observable:hash": [
15-
{
16-
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf"
17-
},
18-
{
19-
"@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21"
20-
},
21-
{
22-
"@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f"
23-
},
24-
{
25-
"@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932"
26-
},
27-
{
28-
"@id": "kb:hash-720759b8-9544-5dab-ab12-003372b17a4e"
29-
},
30-
{
31-
"@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93"
32-
}
33-
],
34-
"uco-observable:sizeInBytes": {
35-
"@type": "xsd:integer",
36-
"@value": "4"
37-
}
38-
},
39-
{
40-
"@id": "kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9",
12+
"@id": "kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9",
4113
"@type": "uco-observable:File",
4214
"uco-core:hasFacet": {
43-
"@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d"
15+
"@id": "kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d"
4416
}
4517
},
4618
{
47-
"@id": "kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04",
19+
"@id": "kb:File-ace6460a-92a9-58b9-83ea-a18ae87f6e04",
4820
"@type": "uco-observable:File",
4921
"uco-core:hasFacet": [
5022
{
51-
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169"
23+
"@id": "kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10"
5224
},
5325
{
54-
"@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10"
26+
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169"
5527
}
5628
]
5729
},
5830
{
59-
"@id": "kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10",
31+
"@id": "kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10",
6032
"@type": "uco-observable:FileFacet",
6133
"uco-observable:fileName": "sample.txt",
6234
"uco-observable:modifiedTime": {
@@ -69,7 +41,7 @@
6941
}
7042
},
7143
{
72-
"@id": "kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d",
44+
"@id": "kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d",
7345
"@type": "uco-observable:FileFacet",
7446
"uco-observable:fileName": "sample.txt",
7547
"uco-observable:modifiedTime": {
@@ -81,6 +53,34 @@
8153
"@value": "4"
8254
}
8355
},
56+
{
57+
"@id": "kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169",
58+
"@type": "uco-observable:ContentDataFacet",
59+
"uco-observable:hash": [
60+
{
61+
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf"
62+
},
63+
{
64+
"@id": "kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21"
65+
},
66+
{
67+
"@id": "kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f"
68+
},
69+
{
70+
"@id": "kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932"
71+
},
72+
{
73+
"@id": "kb:hash-720759b8-9544-5dab-ab12-003372b17a4e"
74+
},
75+
{
76+
"@id": "kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93"
77+
}
78+
],
79+
"uco-observable:sizeInBytes": {
80+
"@type": "xsd:integer",
81+
"@value": "4"
82+
}
83+
},
8484
{
8585
"@id": "kb:hash-24644904-83ea-5911-aea8-be687a9f3caf",
8686
"@type": "uco-types:Hash",

tests/case_utils/case_file/kb.ttl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,46 @@
88
@prefix uco-vocabulary: <https://ontology.unifiedcyberontology.org/uco/vocabulary/> .
99
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1010

11-
kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
12-
a uco-observable:ContentDataFacet ;
13-
uco-observable:hash
14-
kb:hash-24644904-83ea-5911-aea8-be687a9f3caf ,
15-
kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 ,
16-
kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f ,
17-
kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 ,
18-
kb:hash-720759b8-9544-5dab-ab12-003372b17a4e ,
19-
kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93
20-
;
21-
uco-observable:sizeInBytes "4"^^xsd:integer ;
22-
.
23-
24-
kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
11+
kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
2512
a uco-observable:File ;
26-
uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
13+
uco-core:hasFacet kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
2714
.
2815

29-
kb:file-ace6460a-92a9-58b9-83ea-a18ae87f6e04
16+
kb:File-ace6460a-92a9-58b9-83ea-a18ae87f6e04
3017
a uco-observable:File ;
3118
uco-core:hasFacet
32-
kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169 ,
33-
kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10
19+
kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10 ,
20+
kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
3421
;
3522
.
3623

37-
kb:file-facet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10
24+
kb:FileFacet-1297a4bd-563b-54c3-ad8a-f67f01ba9b10
3825
a uco-observable:FileFacet ;
3926
uco-observable:fileName "sample.txt" ;
4027
uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ;
4128
uco-observable:sizeInBytes "4"^^xsd:integer ;
4229
.
4330

44-
kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
31+
kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
4532
a uco-observable:FileFacet ;
4633
uco-observable:fileName "sample.txt" ;
4734
uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ;
4835
uco-observable:sizeInBytes "4"^^xsd:integer ;
4936
.
5037

38+
kb:content-data-facet-1833f979-1f19-5543-9d82-6cefd144b169
39+
a uco-observable:ContentDataFacet ;
40+
uco-observable:hash
41+
kb:hash-24644904-83ea-5911-aea8-be687a9f3caf ,
42+
kb:hash-295bdeb5-7f23-5a3f-8b7f-4bb1191b7c21 ,
43+
kb:hash-39127f5c-598b-51d4-a720-2e949f18f85f ,
44+
kb:hash-49e81fee-c6b3-5f5f-af8b-0746d32e4932 ,
45+
kb:hash-720759b8-9544-5dab-ab12-003372b17a4e ,
46+
kb:hash-b02ebdb3-edf7-5fbf-8088-3d064e316b93
47+
;
48+
uco-observable:sizeInBytes "4"^^xsd:integer ;
49+
.
50+
5151
kb:hash-24644904-83ea-5911-aea8-be687a9f3caf
5252
a uco-types:Hash ;
5353
uco-types:hashMethod "MD5"^^uco-vocabulary:HashNameVocab ;

tests/case_utils/case_file/sample.txt-disable_hashes.ttl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
@prefix uco-observable: <https://ontology.unifiedcyberontology.org/uco/observable/> .
77
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
88

9-
kb:file-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
9+
kb:File-800784de-5c9e-5eb2-b843-0ac51a1bd4b9
1010
a uco-observable:File ;
11-
uco-core:hasFacet kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
11+
uco-core:hasFacet kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d ;
1212
.
1313

14-
kb:file-facet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
14+
kb:FileFacet-ffa3e6bb-dffc-549d-a7c4-ffc5e90ac55d
1515
a uco-observable:FileFacet ;
1616
uco-observable:fileName "sample.txt" ;
1717
uco-observable:modifiedTime "2010-01-02T03:04:56+00:00"^^xsd:dateTime ;

0 commit comments

Comments
 (0)