rara-tools 0.6.10__tar.gz → 0.6.12__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.6.10/rara_tools.egg-info → rara_tools-0.6.12}/PKG-INFO +1 -1
- rara_tools-0.6.12/VERSION +1 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/general.py +4 -2
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/base_record.py +12 -4
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/organization_record.py +34 -5
- {rara_tools-0.6.10 → rara_tools-0.6.12/rara_tools.egg-info}/PKG-INFO +1 -1
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_marc_parsers.py +11 -2
- rara_tools-0.6.10/VERSION +0 -1
- {rara_tools-0.6.10 → rara_tools-0.6.12}/LICENSE.md +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/README.md +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/pyproject.toml +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/__init__.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/digitizer.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/language_evaluator.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/linker.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/meta_extractor.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/normalizers.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/parsers.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/constants/subject_indexer.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/converters.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/decorators.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/digar_schema_converter.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/elastic.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/exceptions.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/normalizers/__init__.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/normalizers/authorities.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/normalizers/base.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/normalizers/bibs.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/normalizers/viaf.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/base_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/ems_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/location_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/organization_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/person_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/title_parser.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/ems_record.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/person_record.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/title_record.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/tools/entity_normalizers.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/tools/marc_converter.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/tools/russian_transliterator.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/s3.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/task_reporter.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/utils.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools.egg-info/SOURCES.txt +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools.egg-info/dependency_links.txt +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools.egg-info/requires.txt +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools.egg-info/top_level.txt +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/requirements.txt +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/setup.cfg +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_digar_schema_converter.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_elastic.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_elastic_vector_and_search_operations.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_entity_normalizers.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_normalization.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_s3_exceptions.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_s3_file_operations.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_sierra_converters.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_task_reporter.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_utils.py +0 -0
- {rara_tools-0.6.10 → rara_tools-0.6.12}/tests/test_viaf_client.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.6.12
|
|
@@ -34,8 +34,10 @@ class Models:
|
|
|
34
34
|
TIME_KEYWORDS_ET = "Ajamärksõnad (ET)"
|
|
35
35
|
TIME_KEYWORDS_EN = "Ajamärksõnad (EN)"
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
UDK_ET = "UDK (ET)"
|
|
38
|
+
UDK_EN = "UDK (EN)"
|
|
39
|
+
UDC_ET = "UDC (ET)"
|
|
40
|
+
UDC_EN = "UDC (EN)"
|
|
39
41
|
|
|
40
42
|
DOMAIN_KEYWORDS_ET = "Märksõnade valdkonnad (ET)"
|
|
41
43
|
DOMAIN_KEYWORDS_EN = "Märksõnade valdkonnad (EN)"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
from typing import List, NoReturn, Tuple
|
|
2
2
|
from abc import abstractmethod
|
|
3
3
|
from pymarc.record import Record
|
|
4
|
+
from pymarc.marcjson import JSONHandler
|
|
4
5
|
from rara_tools.constants.parsers import GeneralMarcIDs
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class BaseRecord:
|
|
8
9
|
""" Implements general logic of parsing MARC files.
|
|
9
10
|
"""
|
|
10
|
-
def __init__(self, record: Record, add_variations: bool = False) -> NoReturn:
|
|
11
|
+
def __init__(self, record: Record | dict, add_variations: bool = False) -> NoReturn:
|
|
11
12
|
""" Initializes BaseRecord object.
|
|
12
13
|
|
|
13
14
|
Parameters
|
|
@@ -21,8 +22,8 @@ class BaseRecord:
|
|
|
21
22
|
via rara-norm-linker, it is necessary to enable this.
|
|
22
23
|
"""
|
|
23
24
|
self.add_variations: bool = add_variations
|
|
24
|
-
self.
|
|
25
|
-
self.__record_dict: dict =
|
|
25
|
+
self.__record_marc: Record = self._get_record_marc(record)
|
|
26
|
+
self.__record_dict: dict = self.marc_record.as_dict()["fields"]
|
|
26
27
|
|
|
27
28
|
self.__id_field_id: List[str] = GeneralMarcIDs.ID
|
|
28
29
|
self.__id_source_field_id: List[str] = GeneralMarcIDs.ID_SOURCE
|
|
@@ -30,6 +31,13 @@ class BaseRecord:
|
|
|
30
31
|
self.__identifier: str = ""
|
|
31
32
|
self.__identifier_source: str = ""
|
|
32
33
|
|
|
34
|
+
def _get_record_marc(self, record: Record | dict) -> Record:
|
|
35
|
+
""" Converts dict-type records into pymarc.Record objects.
|
|
36
|
+
"""
|
|
37
|
+
if isinstance(record, dict):
|
|
38
|
+
record = JSONHandler().elements([record])[0]
|
|
39
|
+
return record
|
|
40
|
+
|
|
33
41
|
def get_values(self,
|
|
34
42
|
marc_ids: List[str],
|
|
35
43
|
subfield_id: str | List[str] = "",
|
|
@@ -101,7 +109,7 @@ class BaseRecord:
|
|
|
101
109
|
|
|
102
110
|
@property
|
|
103
111
|
def marc_record(self) -> Record:
|
|
104
|
-
return self.
|
|
112
|
+
return self.__record_marc
|
|
105
113
|
|
|
106
114
|
@property
|
|
107
115
|
def marc_json_record(self) -> dict:
|
{rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_records/organization_record.py
RENAMED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
from typing import List, NoReturn
|
|
2
2
|
from pymarc.record import Record
|
|
3
3
|
from rara_tools.parsers.marc_records.base_record import BaseRecord
|
|
4
|
-
from rara_tools.constants.parsers import OrganizationMarcIDs
|
|
4
|
+
from rara_tools.constants.parsers import OrganizationMarcIDs, LOGGER
|
|
5
5
|
import regex as re
|
|
6
6
|
import json
|
|
7
7
|
|
|
8
8
|
# TODO: indikaatorid ind1 väljadel 100 ja 400?
|
|
9
|
+
"""
|
|
10
|
+
|c asutuse konverentsi toimumise koht (MK)
|
|
9
11
|
|
|
12
|
+
|d asutuse konverentsi toimumise aeg (K)
|
|
10
13
|
|
|
14
|
+
|n asutuse konverentsi järjenumber (K)
|
|
15
|
+
"""
|
|
11
16
|
class OrganizationRecord(BaseRecord):
|
|
12
17
|
""" Generates a simplified organization JSON record
|
|
13
18
|
from a pymarc MARC record.
|
|
@@ -38,9 +43,8 @@ class OrganizationRecord(BaseRecord):
|
|
|
38
43
|
self.__name: str = ""
|
|
39
44
|
self.__original_name: dict = {}
|
|
40
45
|
self.__name_specification: str = ""
|
|
41
|
-
self.
|
|
42
|
-
self.
|
|
43
|
-
self.__death_year: int = -1
|
|
46
|
+
self.__dates: str = ""
|
|
47
|
+
self.__location: str = ""
|
|
44
48
|
self.__name_variations: List[str] = []
|
|
45
49
|
self.__source: str = ""
|
|
46
50
|
self.__description: str = ""
|
|
@@ -82,7 +86,10 @@ class OrganizationRecord(BaseRecord):
|
|
|
82
86
|
"b": self._clean_value(values[0].get("b", ""))
|
|
83
87
|
}
|
|
84
88
|
else:
|
|
85
|
-
|
|
89
|
+
LOGGER.info(
|
|
90
|
+
f"Could not parse subfields 'a' and/or 'b' from " \
|
|
91
|
+
f"field {self.__name_field_id}. Record:\n{self.marc_record}"
|
|
92
|
+
)
|
|
86
93
|
return self.__original_name
|
|
87
94
|
|
|
88
95
|
@property
|
|
@@ -91,6 +98,28 @@ class OrganizationRecord(BaseRecord):
|
|
|
91
98
|
self.__name = self._merge_and_clean(self.original_name, ["a", "b"])
|
|
92
99
|
return self.__name
|
|
93
100
|
|
|
101
|
+
@property
|
|
102
|
+
def dates(self) -> str:
|
|
103
|
+
if not self.__dates:
|
|
104
|
+
values = self.get_values(
|
|
105
|
+
marc_ids=self.__name_field_id,
|
|
106
|
+
subfield_id=["d"]
|
|
107
|
+
)
|
|
108
|
+
if values:
|
|
109
|
+
self.__dates = self.__clean_value(values[0])
|
|
110
|
+
return self.__dates
|
|
111
|
+
|
|
112
|
+
@property
|
|
113
|
+
def location(self) -> str:
|
|
114
|
+
if not self.__location:
|
|
115
|
+
values = self.get_values(
|
|
116
|
+
marc_ids=self.__name_field_id,
|
|
117
|
+
subfield_id=["c"]
|
|
118
|
+
)
|
|
119
|
+
if values:
|
|
120
|
+
self.__location = self.__clean_value(values[0])
|
|
121
|
+
return self.__location
|
|
122
|
+
|
|
94
123
|
@property
|
|
95
124
|
def acronyms(self) -> List[str]:
|
|
96
125
|
if not self.__acronyms:
|
|
@@ -5,13 +5,17 @@ from rara_tools.parsers.marc_parsers.person_parser import PersonsMARCParser
|
|
|
5
5
|
from rara_tools.parsers.marc_parsers.organization_parser import OrganizationsMARCParser
|
|
6
6
|
from rara_tools.parsers.marc_parsers.location_parser import LocationMARCParser
|
|
7
7
|
from rara_tools.parsers.marc_parsers.title_parser import TitlesMARCParser
|
|
8
|
+
from rara_tools.parsers.marc_records.person_record import PersonRecord
|
|
9
|
+
from tests.test_utils import read_json_file
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
MARC_ROOT_DIR = os.path.join(
|
|
11
|
+
ROOT_DIR = os.path.join("tests", "test_data", "marc_records")
|
|
12
|
+
MARC_ROOT_DIR = os.path.join(ROOT_DIR, "mrc")
|
|
13
|
+
JSON_ROOT_DIR = os.path.join(ROOT_DIR, "json")
|
|
11
14
|
EMS_TEST_FILE = os.path.join(MARC_ROOT_DIR, "ems_test_subset.mrc")
|
|
12
15
|
PER_TEST_FILE = os.path.join(MARC_ROOT_DIR, "per_test_subset.mrc")
|
|
13
16
|
ORG_TEST_FILE = os.path.join(MARC_ROOT_DIR, "org_test_subset.mrc")
|
|
14
17
|
TITLE_TEST_FILE = os.path.join(MARC_ROOT_DIR, "title_test_subset.mrc")
|
|
18
|
+
JSON_TEST_FILE = os.path.join(JSON_ROOT_DIR, "marc_json_record.json")
|
|
15
19
|
|
|
16
20
|
def test_ems_parser_without_variations():
|
|
17
21
|
ems_marc_parser = EMSMARCParser(EMS_TEST_FILE, add_variations=False)
|
|
@@ -56,3 +60,8 @@ def test_title_parser_with_variations():
|
|
|
56
60
|
assert "name" in record
|
|
57
61
|
assert "link_variations" in record
|
|
58
62
|
assert len(record["link_variations"]) > 0
|
|
63
|
+
|
|
64
|
+
def test_creating_marc_record_with_json_input():
|
|
65
|
+
json_data = read_json_file(JSON_TEST_FILE)
|
|
66
|
+
record = PersonRecord(json_data)
|
|
67
|
+
assert record.name == "Koidula, Lydia"
|
rara_tools-0.6.10/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.6.10
|
|
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
|
{rara_tools-0.6.10 → rara_tools-0.6.12}/rara_tools/parsers/marc_parsers/organization_parser.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|