Skip to content

Commit 6ad4bc7

Browse files
committed
Merge branch 'main' into issue_5_message_thread
2 parents 1172259 + 4ad2ddb commit 6ad4bc7

File tree

3 files changed

+43
-31
lines changed

3 files changed

+43
-31
lines changed

mix_utils/utils.py renamed to case_mapping/mix_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from typing import Callable
1+
from typing import Any, Callable
22

33

44
def check_value(
5-
*args: tuple[str, ...],
5+
*args: Any,
66
value: str,
77
list_values: list[str],
8-
list_objects: list[dict],
9-
observable_generating_f: Callable[..., dict]
10-
) -> dict:
8+
list_objects: list[dict[str, Any]],
9+
observable_generating_f: Callable[..., dict[str, Any]]
10+
) -> dict[str, Any]:
1111
"""It checks if a specific value has been already generated related to an ObservableObject relying on
1212
the list of its values. This is meant to avoid duplication in the JSON/CASE file generated by the
1313
parsers (UFED, AXIOM etc.).

case_mapping/uco/observable.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,10 @@ def __init__(self, browser=None, history_entries=None):
527527
# }
528528
# )
529529
# # TODO AJN: This is one instance of xsd:nonNegativeInteger.
530-
# # I'm uncertain at the moment if there are other instances in
531-
# # the ontology requiring nonNegativeIntegers; if so, the
532-
# # FacetEntity class needs to have a helper function added.
530+
# # There are other instances in the ontology requiring
531+
# # nonNegativeIntegers. Hence, the FacetEntity class needs to
532+
# # have a helper function added.
533+
# # https://github.com/casework/CASE-Mapping-Python/issues/37
533534
# self["uco-observable:manuallyEnteredCount"] = {
534535
# "@type": "xsd:nonNegativeInteger",
535536
# "@value": "%d" % manually_entered_count,

mix_utils/test_duplicate.py renamed to tests/test_duplicate.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import uuid
2+
from typing import Any, Union
23

3-
import utils
4+
from case_mapping import mix_utils
45

56

6-
def check_app_name(app_name, app_names, app_objects, uuid):
7-
# c_check = utils.CheckDuplicate()
8-
observable_app = utils.check_value(
7+
def check_app_name(
8+
app_name: str, app_names: list[str], app_objects: list[dict[str, Any]], uuid: str
9+
) -> dict[str, Any]:
10+
# c_check = mix_utils.CheckDuplicate()
11+
observable_app = mix_utils.check_value(
912
app_name,
1013
uuid,
1114
value=app_name,
@@ -16,9 +19,15 @@ def check_app_name(app_name, app_names, app_objects, uuid):
1619
return observable_app
1720

1821

19-
def check_geo_coordinates(latitude, longitude, geo_coordinates, geo_objects, uuid):
20-
# c_check = utils.CheckDuplicate()
21-
observable_app = utils.check_value(
22+
def check_geo_coordinates(
23+
latitude: float,
24+
longitude: float,
25+
geo_coordinates: list[str],
26+
geo_objects: list[dict[str, Any]],
27+
uuid: str,
28+
) -> dict[str, Any]:
29+
# c_check = mix_utils.CheckDuplicate()
30+
observable_app = mix_utils.check_value(
2231
latitude,
2332
longitude,
2433
uuid,
@@ -30,7 +39,7 @@ def check_geo_coordinates(latitude, longitude, geo_coordinates, geo_objects, uui
3039
return observable_app
3140

3241

33-
def generateTraceAppName(app_name, uuid):
42+
def generateTraceAppName(app_name: str, uuid: str) -> dict[str, Any]:
3443
observable = {
3544
"@type": "uco-observable:ApplicationFacet",
3645
"@id": uuid,
@@ -39,19 +48,21 @@ def generateTraceAppName(app_name, uuid):
3948
return observable
4049

4150

42-
def generateTraceLocationCoordinate(latitude, longitude, uuid):
51+
def generateTraceLocationCoordinate(
52+
latitude: Union[float, str], longitude: Union[float, str], uuid: str
53+
) -> dict[str, Any]:
4354
observable = {
4455
"@type": "uco-location:LatLongCoordinatesFacet",
4556
"@id": uuid,
46-
"uco-location:latitude": {"@type": "xsd:decimal", "@value": latitude},
47-
"uco-location:longitude": {"@type": "xsd:decimal", "@value": longitude},
57+
"uco-location:latitude": {"@type": "xsd:decimal", "@value": str(latitude)},
58+
"uco-location:longitude": {"@type": "xsd:decimal", "@value": str(longitude)},
4859
}
4960
return observable
5061

5162

52-
def test_app_name():
53-
app_names = list()
54-
app_objects = list()
63+
def test_app_name() -> None:
64+
app_names: list[str] = list()
65+
app_objects: list[dict[str, Any]] = list()
5566
app_1 = "Safari"
5667
uuid_1 = "kb:" + str(uuid.uuid4())
5768
check_app_name(app_1, app_names, app_objects, uuid_1)
@@ -82,9 +93,9 @@ def test_app_name():
8293
]
8394

8495

85-
def test_geo_coordinates():
86-
geo_coordinates = list()
87-
geo_objects = list()
96+
def test_geo_coordinates() -> None:
97+
geo_coordinates: list[str] = list()
98+
geo_objects: list[dict[str, Any]] = list()
8899
(lat_1, long_1, uuid_1) = (56.47267913, -71.17069244, "kb:" + str(uuid.uuid4()))
89100
check_geo_coordinates(lat_1, long_1, geo_coordinates, geo_objects, uuid_1)
90101
# print(f"\n 1) FT geo_coordinates={geo_coordinates}")
@@ -104,8 +115,8 @@ def test_geo_coordinates():
104115
assert geo_object == {
105116
"@type": "uco-location:LatLongCoordinatesFacet",
106117
"@id": uuid_1,
107-
"uco-location:latitude": {"@type": "xsd:decimal", "@value": lat_1},
108-
"uco-location:longitude": {"@type": "xsd:decimal", "@value": long_1},
118+
"uco-location:latitude": {"@type": "xsd:decimal", "@value": str(lat_1)},
119+
"uco-location:longitude": {"@type": "xsd:decimal", "@value": str(long_1)},
109120
}
110121
# print(f"\n 3) FT geo_coordinates={geo_coordinates}")
111122
assert geo_coordinates == [
@@ -122,13 +133,13 @@ def test_geo_coordinates():
122133
{
123134
"@type": "uco-location:LatLongCoordinatesFacet",
124135
"@id": uuid_1,
125-
"uco-location:latitude": {"@type": "xsd:decimal", "@value": lat_1},
126-
"uco-location:longitude": {"@type": "xsd:decimal", "@value": long_1},
136+
"uco-location:latitude": {"@type": "xsd:decimal", "@value": str(lat_1)},
137+
"uco-location:longitude": {"@type": "xsd:decimal", "@value": str(long_1)},
127138
},
128139
{
129140
"@type": "uco-location:LatLongCoordinatesFacet",
130141
"@id": uuid_2,
131-
"uco-location:latitude": {"@type": "xsd:decimal", "@value": lat_2},
132-
"uco-location:longitude": {"@type": "xsd:decimal", "@value": long_2},
142+
"uco-location:latitude": {"@type": "xsd:decimal", "@value": str(lat_2)},
143+
"uco-location:longitude": {"@type": "xsd:decimal", "@value": str(long_2)},
133144
},
134145
]

0 commit comments

Comments
 (0)