rara-tools 0.7.9__tar.gz → 0.7.10__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.7.9/rara_tools.egg-info → rara_tools-0.7.10}/PKG-INFO +1 -1
- rara_tools-0.7.10/VERSION +1 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/authorities.py +0 -2
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/base.py +13 -8
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/bibs.py +1 -1
- {rara_tools-0.7.9 → rara_tools-0.7.10/rara_tools.egg-info}/PKG-INFO +1 -1
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_normalization.py +20 -5
- rara_tools-0.7.9/VERSION +0 -1
- {rara_tools-0.7.9 → rara_tools-0.7.10}/LICENSE.md +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/README.md +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/pyproject.toml +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/__init__.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/digitizer.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/general.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/language_evaluator.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/linker.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/meta_extractor.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/normalizers.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/parsers.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/constants/subject_indexer.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/converters.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/core_formatters/core_formatter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/core_formatters/formatted_keyword.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/core_formatters/formatted_meta.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/core_formatters/formatted_object.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/decorators.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/digar_schema_converter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/elastic.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/exceptions.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/__init__.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/reader.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/normalizers/viaf.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/base_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/ems_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/location_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/organization_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/person_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_parsers/title_parser.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_records/base_record.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_records/ems_record.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_records/organization_record.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_records/person_record.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/marc_records/title_record.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/tools/entity_normalizers.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/tools/marc_converter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/parsers/tools/russian_transliterator.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/s3.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/task_reporter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools/utils.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools.egg-info/SOURCES.txt +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools.egg-info/dependency_links.txt +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools.egg-info/requires.txt +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/rara_tools.egg-info/top_level.txt +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/requirements.txt +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/setup.cfg +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_digar_schema_converter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_elastic.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_elastic_vector_and_search_operations.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_entity_normalizers.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_formatters.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_marc_parsers.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_s3_exceptions.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_s3_file_operations.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_sierra_converters.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_task_reporter.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_utils.py +0 -0
- {rara_tools-0.7.9 → rara_tools-0.7.10}/tests/test_viaf_client.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.7.10
|
|
@@ -69,7 +69,6 @@ class AuthoritiesRecordNormalizer(RecordNormalizer):
|
|
|
69
69
|
record, [Field(tag="046", indicators=EMPTY_INDICATORS, subfields=subfields_046)])
|
|
70
70
|
|
|
71
71
|
def _add_viaf_url_or_isni(self, record: Record, viaf_record: VIAFRecord) -> None:
|
|
72
|
-
# TODO 024. will be used to store KRATT KATA ID. Just generate one?
|
|
73
72
|
viaf_url = f"https://viaf.org/viaf/{viaf_record.viaf_id}"
|
|
74
73
|
|
|
75
74
|
subfields = [Subfield("0", self.get_subfield(
|
|
@@ -109,7 +108,6 @@ class AuthoritiesRecordNormalizer(RecordNormalizer):
|
|
|
109
108
|
100, 110, 111 - non-repeatable field, attempts to add author type, if missing.
|
|
110
109
|
|
|
111
110
|
"""
|
|
112
|
-
# TODO: include KRATT KATA ID to 024 and remove on delete. Increment last elastic ID?
|
|
113
111
|
if not viaf_record:
|
|
114
112
|
return
|
|
115
113
|
|
|
@@ -147,21 +147,26 @@ class RecordNormalizer:
|
|
|
147
147
|
return filter(lambda field: not self._field_in_record(field, record), fields)
|
|
148
148
|
|
|
149
149
|
def _format_date(self, value: str) -> str:
|
|
150
|
-
|
|
150
|
+
|
|
151
|
+
if not value:
|
|
151
152
|
return ""
|
|
152
153
|
|
|
153
154
|
if isinstance(value, (datetime, date)):
|
|
154
|
-
return value.strftime(
|
|
155
|
+
return value.strftime("%Y%m%d")
|
|
156
|
+
|
|
157
|
+
val = str(value).strip()
|
|
155
158
|
|
|
156
159
|
try:
|
|
157
|
-
dt = parser.parse(
|
|
158
|
-
|
|
159
|
-
logger.info(f"Formatted date '{formatted_date}' from value '{value}'")
|
|
160
|
-
return formatted_date
|
|
161
|
-
except Exception as e:
|
|
162
|
-
logger.info(f"Failed to format date string '{value}': {e}")
|
|
160
|
+
dt = parser.parse(val, fuzzy=False, default=datetime(1, 1, 1))
|
|
161
|
+
except Exception:
|
|
163
162
|
return ""
|
|
164
163
|
|
|
164
|
+
if len(val) == 4 and val.isdigit():
|
|
165
|
+
return dt.strftime("%Y") # YYYY
|
|
166
|
+
if len(val) in (6, 7): # YYYYMM or YYYY-MM
|
|
167
|
+
return dt.strftime("%Y%m") # YYYYMM
|
|
168
|
+
return dt.strftime("%Y%m%d") # YYYYMMDD
|
|
169
|
+
|
|
165
170
|
def get_subfield(self, record: Record, tag: str, subfield: str, default: str) -> str:
|
|
166
171
|
""" get record existing subfield value or assign a fallback value. """
|
|
167
172
|
|
|
@@ -385,7 +385,7 @@ def test_add_birth_and_death_dates():
|
|
|
385
385
|
normalizer._add_birth_and_death_dates(record, viaf_record)
|
|
386
386
|
|
|
387
387
|
field_046 = str(record.get_fields("046")[0])
|
|
388
|
-
assert field_046 == "=046 \\\\$
|
|
388
|
+
assert field_046 == "=046 \\\\$f19160107$g19750605"
|
|
389
389
|
|
|
390
390
|
# Case two: viaf record has birth date, but no death date (author still alive)
|
|
391
391
|
viaf_record = normalizer._get_viaf_record(
|
|
@@ -402,7 +402,7 @@ def test_add_birth_and_death_dates():
|
|
|
402
402
|
|
|
403
403
|
field_046 = str(record.get_fields("046")[0])
|
|
404
404
|
# empty indicators represented with \
|
|
405
|
-
assert field_046 == "=046 \\\\$
|
|
405
|
+
assert field_046 == "=046 \\\\$f19700817"
|
|
406
406
|
|
|
407
407
|
def test_add_nationality():
|
|
408
408
|
""" Test adding nationality from VIAF record to 043 field """
|
|
@@ -613,6 +613,21 @@ def test_680_field_on_existing_record_moved_to_667():
|
|
|
613
613
|
fields_667 = record.get_fields("667")
|
|
614
614
|
assert len(fields_667) == 3 # original + moved from 680 + new note
|
|
615
615
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
616
|
+
def test_date_formatting():
|
|
617
|
+
normalizer = AuthoritiesRecordNormalizer()
|
|
618
|
+
|
|
619
|
+
dates = {
|
|
620
|
+
"19700712": "19700712",
|
|
621
|
+
"1970": "1970",
|
|
622
|
+
"1970-07": "197007",
|
|
623
|
+
"2001-12-31": "20011231",
|
|
624
|
+
"1999-01": "199901",
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
for input_date, expected in dates.items():
|
|
628
|
+
assert normalizer._format_date(input_date) == expected
|
|
629
|
+
|
|
630
|
+
# invalid date formats - should return empty string
|
|
631
|
+
invalid_dates = ["abcd", "199A0101"]
|
|
632
|
+
for date in invalid_dates:
|
|
633
|
+
assert normalizer._format_date(date) == ""
|
rara_tools-0.7.9/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.7.9
|
|
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
|
{rara_tools-0.7.9 → rara_tools-0.7.10}/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.7.9 → rara_tools-0.7.10}/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
|
|
File without changes
|