rara-tools 0.4.2__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rara-tools might be problematic. Click here for more details.
- {rara_tools-0.4.2/rara_tools.egg-info → rara_tools-0.4.4}/PKG-INFO +1 -1
- rara_tools-0.4.4/VERSION +1 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/converters.py +42 -4
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/elastic.py +11 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4/rara_tools.egg-info}/PKG-INFO +1 -1
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_sierra_converters.py +2 -11
- rara_tools-0.4.2/VERSION +0 -1
- {rara_tools-0.4.2 → rara_tools-0.4.4}/LICENSE.md +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/README.md +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/pyproject.toml +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/__init__.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/digitizer.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/general.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/linker.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/normalizers.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/constants/parsers.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/decorators.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/digar_schema_converter.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/exceptions.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/normalizers/__init__.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/normalizers/authorities.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/normalizers/base.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/normalizers/bibs.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/normalizers/viaf.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/base_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/ems_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/location_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/organization_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/person_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/title_parser.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/base_record.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/ems_record.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/organization_record.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/person_record.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/title_record.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/tools/entity_normalizers.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/tools/marc_converter.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/tools/russian_transliterator.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/s3.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/task_reporter.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/utils.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools.egg-info/SOURCES.txt +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools.egg-info/dependency_links.txt +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools.egg-info/requires.txt +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools.egg-info/top_level.txt +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/requirements.txt +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/setup.cfg +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_digar_schema_converter.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_elastic.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_elastic_vector_and_search_operations.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_entity_normalizers.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_marc_parsers.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_normalization.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_s3_exceptions.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_s3_file_operations.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_task_reporter.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_utils.py +0 -0
- {rara_tools-0.4.2 → rara_tools-0.4.4}/tests/test_viaf_client.py +0 -0
rara_tools-0.4.4/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.4.4
|
|
@@ -14,9 +14,46 @@ class SierraResponseConverter:
|
|
|
14
14
|
def _map_control_fields(field: dict) -> dict:
|
|
15
15
|
# for tags < 010, no subfields, instead one str value in "value"
|
|
16
16
|
return {field["tag"]: field["value"]}
|
|
17
|
+
|
|
18
|
+
def _map_data_field_subfields(self, subfields: list) -> list:
|
|
19
|
+
""" Maps data field subfields to the standardised format, if necessary.
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
Args:
|
|
22
|
+
subfields (list): List of subfields in format e.g
|
|
23
|
+
"subfields": [
|
|
24
|
+
{
|
|
25
|
+
"code": "a",
|
|
26
|
+
"data": "foo"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"code": "c",
|
|
30
|
+
"data": "by me."
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
list: standardised marc-in-json format. e.g
|
|
36
|
+
"subfields": [
|
|
37
|
+
{ "a": "foo /" },
|
|
38
|
+
{ "c": "by me." }
|
|
39
|
+
]
|
|
40
|
+
"""
|
|
41
|
+
result = []
|
|
42
|
+
for subfield in subfields:
|
|
43
|
+
|
|
44
|
+
code = subfield.get("code")
|
|
45
|
+
data = subfield.get("data")
|
|
46
|
+
|
|
47
|
+
if not code or not data:
|
|
48
|
+
# assume that the subfield is already in the correct format
|
|
49
|
+
return subfields
|
|
50
|
+
else:
|
|
51
|
+
result.append({code: data})
|
|
52
|
+
|
|
53
|
+
return result
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _map_data_fields(self, field: dict) -> dict:
|
|
20
57
|
""" Maps marc fields > 010.
|
|
21
58
|
|
|
22
59
|
Args:
|
|
@@ -27,12 +64,13 @@ class SierraResponseConverter:
|
|
|
27
64
|
"""
|
|
28
65
|
|
|
29
66
|
data = field["data"]
|
|
67
|
+
subfields = data.get("subfields", [])
|
|
30
68
|
|
|
31
69
|
# Order matters ind1, in2, subfields
|
|
32
70
|
field_data = {
|
|
33
71
|
"ind1": data.get("ind1", " "),
|
|
34
72
|
"ind2": data.get("ind2", " "),
|
|
35
|
-
"subfields":
|
|
73
|
+
"subfields": self._map_data_field_subfields(subfields)
|
|
36
74
|
}
|
|
37
75
|
|
|
38
76
|
return {field["tag"]: field_data}
|
|
@@ -41,7 +79,7 @@ class SierraResponseConverter:
|
|
|
41
79
|
def _is_marc21structured(field: dict) -> bool:
|
|
42
80
|
"""Checks if the field is already structured according to MARC21 in JSON"""
|
|
43
81
|
return any(key.isdigit() for key in field.keys())
|
|
44
|
-
|
|
82
|
+
|
|
45
83
|
def _handle_field_type(self, field: dict) -> dict:
|
|
46
84
|
|
|
47
85
|
if self._is_marc21structured(field):
|
|
@@ -203,6 +203,17 @@ class KataElastic:
|
|
|
203
203
|
actions = [{"_index": last_index_name, "_source": document} for document in documents]
|
|
204
204
|
successful_count, error_count = bulk(actions=actions, client=self.elasticsearch, max_retries=3, refresh=refresh)
|
|
205
205
|
return successful_count, error_count
|
|
206
|
+
|
|
207
|
+
@_elastic_connection
|
|
208
|
+
def bulk_index_without_rollver(
|
|
209
|
+
self,
|
|
210
|
+
documents: Iterator[dict],
|
|
211
|
+
index: str,
|
|
212
|
+
refresh="false",
|
|
213
|
+
) -> (int, int):
|
|
214
|
+
actions = [{"_index": index, "_source": document} for document in documents]
|
|
215
|
+
successful_count, error_count = bulk(actions=actions, client=self.elasticsearch, max_retries=3, refresh=refresh)
|
|
216
|
+
return successful_count, error_count
|
|
206
217
|
|
|
207
218
|
@_elastic_connection
|
|
208
219
|
def index_document(self, index: str, body: dict, document_id: Optional[str] = None) -> Dict:
|
|
@@ -44,25 +44,16 @@ example_res = {
|
|
|
44
44
|
def test_convert_bibs_response():
|
|
45
45
|
|
|
46
46
|
data = get_formatted_sierra_response("bibs.json")
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
expected = read_json_file(os.path.join(SIERRA_OUTPUT_DIR, "bibs.json"))
|
|
49
49
|
|
|
50
50
|
assert compare_results(expected, data)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def test_convert_keywords_response():
|
|
54
|
-
|
|
55
|
-
data = get_formatted_sierra_response("keywords.json")
|
|
56
|
-
|
|
57
|
-
expected = read_json_file(os.path.join(SIERRA_OUTPUT_DIR, "keywords.json"))
|
|
58
|
-
|
|
59
|
-
assert compare_results(expected, data)
|
|
60
|
-
|
|
61
|
-
|
|
62
53
|
def test_convert_authorities_response():
|
|
63
54
|
|
|
64
55
|
data = get_formatted_sierra_response("authorities.json")
|
|
65
|
-
|
|
56
|
+
|
|
66
57
|
expected = read_json_file(os.path.join(
|
|
67
58
|
SIERRA_OUTPUT_DIR, "authorities.json"))
|
|
68
59
|
|
rara_tools-0.4.2/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.4.2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/organization_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rara_tools-0.4.2 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/organization_record.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|