-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
# Conflicts: # acacore/siegfried/siegfried.py
- Loading branch information
Showing
14 changed files
with
180 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from . import file_data | ||
from . import identification | ||
from . import metadata | ||
from . import reference_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Data models for the data on saved to different .json files on the `reference_files` repo.""" | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class ReIdentifyModel(BaseModel): | ||
"""Data model for the `to_reidentify` from reference_files.""" | ||
|
||
puid: Optional[str] = None | ||
name: Optional[str] = None | ||
ext: Optional[str] = None | ||
reasoning: Optional[str] = None | ||
|
||
|
||
class CustomSignature(BaseModel): | ||
"""Data model for the `costum_signatures` from reference_files.""" | ||
|
||
bof: Optional[str] = None | ||
eof: Optional[str] = None | ||
operator: Optional[str] = None | ||
puid: Optional[str] = None | ||
signature: Optional[str] = None | ||
extension: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"""Collection of methods that allows us to """ | ||
from . import ref_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import json | ||
from functools import lru_cache | ||
from http.client import HTTPResponse | ||
from urllib import request | ||
|
||
from models.reference_files import CustomSignature, ReIdentifyModel | ||
|
||
|
||
@lru_cache | ||
def to_re_identify() -> list[ReIdentifyModel]: | ||
"""Gets the json file with the different formats that we wish to reidentify. | ||
Is kept updated on the reference-files repo. The function caches the result, | ||
soo multiple calls in the same run should not be an issue. | ||
""" | ||
response: HTTPResponse = request.urlopen( | ||
"https://raw.githubusercontent.com/aarhusstadsarkiv/reference-files/main/to_reidentify.json", | ||
) | ||
if response.getcode() != 200: | ||
raise ConnectionError | ||
|
||
re_identify_map: dict[str, str] = json.loads(response.read()) | ||
|
||
if re_identify_map is None: | ||
raise ConnectionError | ||
|
||
result_list: list[ReIdentifyModel] = [] | ||
for key, values in re_identify_map.items(): | ||
result = ReIdentifyModel(puid=key, **values) | ||
result_list.append(result) | ||
|
||
return result_list | ||
|
||
|
||
@lru_cache | ||
def costum_sigs() -> list[CustomSignature]: | ||
"""Gets the json file with our own costum formats in a list. | ||
Is kept updated on the reference-files repo. The function caches the result, | ||
soo multiple calls in the same run should not be an issue. | ||
""" | ||
response: HTTPResponse = request.urlopen( | ||
"https://raw.githubusercontent.com/aarhusstadsarkiv/reference-files/main/custom_signatures.json", | ||
) | ||
if response.getcode() != 200: | ||
raise ConnectionError | ||
|
||
custom_list: list[dict] = json.loads(response.read()) | ||
|
||
if custom_list is None: | ||
raise ConnectionError | ||
|
||
result_list: list[CustomSignature] = [] | ||
|
||
for values in custom_list: | ||
result = CustomSignature(**values) | ||
result_list.append(result) | ||
|
||
return result_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters