rara-tools 0.4.3__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.

Files changed (58) hide show
  1. {rara_tools-0.4.3/rara_tools.egg-info → rara_tools-0.4.4}/PKG-INFO +1 -1
  2. rara_tools-0.4.4/VERSION +1 -0
  3. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/converters.py +42 -4
  4. {rara_tools-0.4.3 → rara_tools-0.4.4/rara_tools.egg-info}/PKG-INFO +1 -1
  5. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_sierra_converters.py +2 -11
  6. rara_tools-0.4.3/VERSION +0 -1
  7. {rara_tools-0.4.3 → rara_tools-0.4.4}/LICENSE.md +0 -0
  8. {rara_tools-0.4.3 → rara_tools-0.4.4}/README.md +0 -0
  9. {rara_tools-0.4.3 → rara_tools-0.4.4}/pyproject.toml +0 -0
  10. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/__init__.py +0 -0
  11. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/digitizer.py +0 -0
  12. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/general.py +0 -0
  13. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/linker.py +0 -0
  14. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/normalizers.py +0 -0
  15. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/constants/parsers.py +0 -0
  16. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/decorators.py +0 -0
  17. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/digar_schema_converter.py +0 -0
  18. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/elastic.py +0 -0
  19. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/exceptions.py +0 -0
  20. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/normalizers/__init__.py +0 -0
  21. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/normalizers/authorities.py +0 -0
  22. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/normalizers/base.py +0 -0
  23. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/normalizers/bibs.py +0 -0
  24. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/normalizers/viaf.py +0 -0
  25. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/base_parser.py +0 -0
  26. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/ems_parser.py +0 -0
  27. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/location_parser.py +0 -0
  28. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/organization_parser.py +0 -0
  29. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/person_parser.py +0 -0
  30. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_parsers/title_parser.py +0 -0
  31. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/base_record.py +0 -0
  32. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/ems_record.py +0 -0
  33. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/organization_record.py +0 -0
  34. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/person_record.py +0 -0
  35. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/marc_records/title_record.py +0 -0
  36. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/tools/entity_normalizers.py +0 -0
  37. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/tools/marc_converter.py +0 -0
  38. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/parsers/tools/russian_transliterator.py +0 -0
  39. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/s3.py +0 -0
  40. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/task_reporter.py +0 -0
  41. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools/utils.py +0 -0
  42. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools.egg-info/SOURCES.txt +0 -0
  43. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools.egg-info/dependency_links.txt +0 -0
  44. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools.egg-info/requires.txt +0 -0
  45. {rara_tools-0.4.3 → rara_tools-0.4.4}/rara_tools.egg-info/top_level.txt +0 -0
  46. {rara_tools-0.4.3 → rara_tools-0.4.4}/requirements.txt +0 -0
  47. {rara_tools-0.4.3 → rara_tools-0.4.4}/setup.cfg +0 -0
  48. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_digar_schema_converter.py +0 -0
  49. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_elastic.py +0 -0
  50. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_elastic_vector_and_search_operations.py +0 -0
  51. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_entity_normalizers.py +0 -0
  52. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_marc_parsers.py +0 -0
  53. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_normalization.py +0 -0
  54. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_s3_exceptions.py +0 -0
  55. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_s3_file_operations.py +0 -0
  56. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_task_reporter.py +0 -0
  57. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_utils.py +0 -0
  58. {rara_tools-0.4.3 → rara_tools-0.4.4}/tests/test_viaf_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rara-tools
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Tools to support Kata's work.
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -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
- @staticmethod
19
- def _map_data_fields(field: dict) -> dict:
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": data.get("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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rara-tools
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Tools to support Kata's work.
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Python :: 3.10
@@ -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.3/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.3
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes