folio-migration-tools 1.9.0a4__py3-none-any.whl → 1.9.0a6__py3-none-any.whl

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.
@@ -24,6 +24,7 @@ from folio_migration_tools.mapping_file_transformation.ref_data_mapping import (
24
24
  RefDataMapping,
25
25
  )
26
26
  from folio_migration_tools.migration_report import MigrationReport
27
+ from folio_migration_tools.task_configuration import AbstractTaskConfiguration
27
28
 
28
29
 
29
30
  class MapperBase:
@@ -42,7 +43,7 @@ class MapperBase:
42
43
  self.start_datetime = datetime.now(timezone.utc)
43
44
  self.folio_client: FolioClient = folio_client
44
45
  self.library_configuration: LibraryConfiguration = library_configuration
45
-
46
+ self.task_configuration: AbstractTaskConfiguration
46
47
  self.mapped_folio_fields: dict = {}
47
48
  self.migration_report: MigrationReport = MigrationReport()
48
49
  self.num_criticalerrors = 0
@@ -267,7 +268,13 @@ class MapperBase:
267
268
  sys.exit(1)
268
269
 
269
270
  def get_id_map_tuple(self, legacy_id: str, folio_record: dict, object_type: FOLIONamespaces):
270
- if object_type == FOLIONamespaces.instances:
271
+ if all(
272
+ [
273
+ object_type == FOLIONamespaces.instances,
274
+ (not getattr(self.task_configuration, "data_import_marc", False)),
275
+ getattr(self.task_configuration, "create_source_records", True),
276
+ ]
277
+ ):
271
278
  return (legacy_id, folio_record["id"], folio_record["hrid"])
272
279
  return (legacy_id, folio_record["id"])
273
280
 
@@ -6,9 +6,7 @@ import httpx
6
6
  import i18n
7
7
  from folio_uuid import FOLIONamespaces
8
8
  from folioclient import FolioClient
9
- from pymarc import Field
10
- from pymarc import Record
11
- from pymarc import Subfield
9
+ from pymarc import Field, Record, Subfield
12
10
 
13
11
  from folio_migration_tools.custom_exceptions import TransformationProcessError
14
12
  from folio_migration_tools.helper import Helper
@@ -220,7 +218,7 @@ class HRIDHandler:
220
218
  ),
221
219
  )
222
220
  self.handle_035_generation(
223
- marc_record, legacy_ids, self.migration_report, self.deactivate035_from001
221
+ marc_record, legacy_ids, self.migration_report, self.deactivate035_from001, False
224
222
  )
225
223
  Helper.log_data_issue(
226
224
  legacy_ids,
@@ -32,7 +32,7 @@ class MarcFileProcessor:
32
32
  self.created_objects_file = created_objects_file
33
33
  if mapper.task_configuration.create_source_records:
34
34
  self.srs_records_file = open(self.folder_structure.srs_records_path, "w+")
35
- if mapper.task_configuration.data_import_marc:
35
+ if getattr(mapper.task_configuration, "data_import_marc", False):
36
36
  self.data_import_marc_file = open(self.folder_structure.data_import_marc_path, "wb+")
37
37
  self.unique_001s: set = set()
38
38
  self.failed_records_count: int = 0
@@ -87,7 +87,7 @@ class MarcFileProcessor:
87
87
  legacy_ids,
88
88
  self.object_type,
89
89
  )
90
- if self.mapper.task_configuration.data_import_marc:
90
+ if getattr(self.mapper.task_configuration, "data_import_marc", False):
91
91
  self.save_marc_record(
92
92
  marc_record,
93
93
  folio_rec,
@@ -271,7 +271,7 @@ class MarcFileProcessor:
271
271
  if not self.srs_records_file.seek(0):
272
272
  os.remove(self.srs_records_file.name)
273
273
  self.srs_records_file.close()
274
- if self.mapper.task_configuration.data_import_marc:
274
+ if getattr(self.mapper.task_configuration, "data_import_marc", False):
275
275
  self.data_import_marc_file.seek(0)
276
276
  if not self.data_import_marc_file.read(1):
277
277
  os.remove(self.data_import_marc_file.name)
@@ -24,6 +24,7 @@ from folio_migration_tools.custom_exceptions import (
24
24
  from folio_migration_tools.helper import Helper
25
25
  from folio_migration_tools.library_configuration import (
26
26
  FileDefinition,
27
+ HridHandling,
27
28
  IlsFlavour,
28
29
  LibraryConfiguration,
29
30
  )
@@ -59,9 +60,11 @@ class BibsRulesMapper(RulesMapperBase):
59
60
  self.instance_relationship_types: dict = {}
60
61
  self.other_mode_of_issuance_id = get_unspecified_mode_of_issuance(self.folio_client)
61
62
  self.create_source_records = all(
62
- [self.task_configuration.create_source_records, (not self.task_configuration.data_import_marc)]
63
+ [self.task_configuration.create_source_records, (not getattr(self.task_configuration, "data_import_marc", False))]
63
64
  )
64
65
  self.data_import_marc = self.task_configuration.data_import_marc
66
+ if self.data_import_marc:
67
+ self.hrid_handler.deactivate035_from001 = True
65
68
  self.start = time.time()
66
69
 
67
70
  def perform_initial_preparation(self, marc_record: pymarc.Record, legacy_ids):
@@ -73,7 +76,7 @@ class BibsRulesMapper(RulesMapperBase):
73
76
  str(legacy_ids[-1]),
74
77
  )
75
78
  )
76
- if self.create_source_records:
79
+ if self.create_source_records or self.hrid_handler.handling == HridHandling.preserve001:
77
80
  self.hrid_handler.handle_hrid(
78
81
  FOLIONamespaces.instances,
79
82
  folio_instance,
@@ -118,7 +121,7 @@ class BibsRulesMapper(RulesMapperBase):
118
121
  bad_tags = set(self.task_configuration.tags_to_delete) # "907"
119
122
  folio_instance = self.perform_initial_preparation(marc_record, legacy_ids)
120
123
  if self.data_import_marc:
121
- self.simple_bib_map(marc_record, folio_instance, ignored_subsequent_fields, legacy_ids)
124
+ self.simple_bib_map(folio_instance, marc_record, ignored_subsequent_fields, legacy_ids)
122
125
  else:
123
126
  for marc_field in marc_record:
124
127
  self.report_marc_stats(marc_field, bad_tags, legacy_ids, ignored_subsequent_fields)
@@ -152,7 +155,13 @@ class BibsRulesMapper(RulesMapperBase):
152
155
  legacy_ids (List[str]): _description_
153
156
  file_def (FileDefinition): _description_
154
157
  """
155
- self.process_marc_field(folio_instnace, marc_record['245'], ignored_subsequent_fields, legacy_ids)
158
+ try:
159
+ self.process_marc_field(folio_instnace, marc_record['245'], ignored_subsequent_fields, legacy_ids)
160
+ except KeyError:
161
+ raise TransformationRecordFailedError(
162
+ legacy_ids,
163
+ "No 245 field in MARC record"
164
+ )
156
165
 
157
166
  def perform_additional_parsing(
158
167
  self,
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: folio_migration_tools
3
- Version: 1.9.0a4
3
+ Version: 1.9.0a6
4
4
  Summary: A tool allowing you to migrate data from legacy ILS:s (Library systems) into FOLIO LSP
5
- Home-page: https://github.com/FOLIO-FSE/folio_migration_tools
6
5
  License: MIT
7
6
  Keywords: FOLIO,ILS,LSP,Library Systems,MARC21,Library data
8
7
  Author: Theodor Tolstoy
@@ -27,6 +26,7 @@ Requires-Dist: pyhumps (>=3.7.3,<4.0.0)
27
26
  Requires-Dist: pymarc (>=5.2.3,<6.0.0)
28
27
  Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
29
28
  Requires-Dist: python-i18n (>=0.3.9,<0.4.0)
29
+ Project-URL: Homepage, https://github.com/FOLIO-FSE/folio_migration_tools
30
30
  Project-URL: Repository, https://github.com/FOLIO-FSE/folio_migration_tools
31
31
  Description-Content-Type: text/markdown
32
32
 
@@ -11,7 +11,7 @@ folio_migration_tools/helper.py,sha256=KkOkNAGO_fuYqxdLrsbLzCJLQHUrFZG1NzD4RmpQ-
11
11
  folio_migration_tools/holdings_helper.py,sha256=yJpz6aJrKRBiJ1MtT5bs2vXAc88uJuGh2_KDuCySOKc,7559
12
12
  folio_migration_tools/i18n_config.py,sha256=3AH_2b9zTsxE4XTe4isM_zYtPJSlK0ix6eBmV7kAYUM,228
13
13
  folio_migration_tools/library_configuration.py,sha256=60hgGtyvHhRUKXHvqz41-2V5EtUaySMV20JIKk279N0,3636
14
- folio_migration_tools/mapper_base.py,sha256=46eO9wAxGoXZJC3SI7BNh-X7779SKSM8a8KXqdR9S8Y,19942
14
+ folio_migration_tools/mapper_base.py,sha256=dmwsgeolBWjmzaztms5r1_7OG2PlTcp0D74TQCE6cgk,20303
15
15
  folio_migration_tools/mapping_file_transformation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  folio_migration_tools/mapping_file_transformation/courses_mapper.py,sha256=mJQxxeTn1bCYb2zwFYyXJ6EGZpJ0DsmwOY3nED7D_gQ,8091
17
17
  folio_migration_tools/mapping_file_transformation/holdings_mapper.py,sha256=GI9xnN74EsUMAshXKNJ6p9bGPdLtK0PCXqbB3nIxrC8,7207
@@ -26,13 +26,13 @@ folio_migration_tools/mapping_file_transformation/user_mapper.py,sha256=oWuIPRQL
26
26
  folio_migration_tools/marc_rules_transformation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  folio_migration_tools/marc_rules_transformation/conditions.py,sha256=MnbMThiOZ6IenXirjMSNkqJ86RtFzbF4cp1T4YcfpyA,36349
28
28
  folio_migration_tools/marc_rules_transformation/holdings_statementsparser.py,sha256=lTb5QWEAgwyFHy5vdSK6oDl1Q5v2GnzuV04xWV3p4rc,12401
29
- folio_migration_tools/marc_rules_transformation/hrid_handler.py,sha256=lEvtJFWe5FoU372nHqTdnVF76qCKZjWgUJqIpiKUHY0,10026
29
+ folio_migration_tools/marc_rules_transformation/hrid_handler.py,sha256=Ihdv0_1q7gL_pZ3HWU3GcfV_jjpIfOLithWk9z_uH3Y,9997
30
30
  folio_migration_tools/marc_rules_transformation/loc_language_codes.xml,sha256=ztn2_yKws6qySL4oSsZh7sOjxq5bCC1PhAnXJdtgmJ0,382912
31
- folio_migration_tools/marc_rules_transformation/marc_file_processor.py,sha256=vP6u8BDrf3v5q-scIPEINXYUL223cmreAQ8BUr9WCcM,12292
31
+ folio_migration_tools/marc_rules_transformation/marc_file_processor.py,sha256=WkOQRDi7f4PZ5qmVH3Q-1_zdGEKYSvOGC6jixDwDp98,12349
32
32
  folio_migration_tools/marc_rules_transformation/marc_reader_wrapper.py,sha256=9ATjYMRAjy0QcXtmNZaHVhHLJ5hE1WUgOcF6KMJjbgo,5309
33
33
  folio_migration_tools/marc_rules_transformation/rules_mapper_authorities.py,sha256=GFw8j9UtCxnUdLShmPzJa1MpCK8a0NkQIN5C3jyouRs,9604
34
34
  folio_migration_tools/marc_rules_transformation/rules_mapper_base.py,sha256=WWSJgYvF9LeY8vh-BtQi7Fm3J-cowUJKWa0Wk2Ge7fc,39358
35
- folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py,sha256=ys27z3PGF0I4RQfTXYB-YMgs-2nyNS3L70mkXEFnwLY,28555
35
+ folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py,sha256=ckVeysbpW9s19pmHvogdRFOCouzz17Y6oKJD0_QfQAk,28924
36
36
  folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py,sha256=EBxf9Qh5Y0eDOmqYssWfaizxafiXSYDFzWmCuPtdG-8,18226
37
37
  folio_migration_tools/migration_report.py,sha256=BkRspM1hwTBnWeqsHamf7yVEofzLj560Q-9G--O00hw,4258
38
38
  folio_migration_tools/migration_tasks/__init__.py,sha256=ZkbY_yGyB84Ke8OMlYUzyyBj4cxxNrhMTwQlu_GbdDs,211
@@ -60,7 +60,7 @@ folio_migration_tools/transaction_migration/legacy_request.py,sha256=1ulyFzPQw_I
60
60
  folio_migration_tools/transaction_migration/legacy_reserve.py,sha256=rZVtiMBYnt6aI0WxAwPN8fML_MKEUSUYsadCKPTeB4E,1839
61
61
  folio_migration_tools/transaction_migration/transaction_result.py,sha256=cTdCN0BnlI9_ZJB2Z3Fdkl9gpymIi-9mGZsRFlQcmDk,656
62
62
  folio_migration_tools/translations/en.json,sha256=HOVpkb_T-SN_x0NpDp8gyvV1hMLCui3SsG7ByyIv0OU,38669
63
- folio_migration_tools-1.9.0a4.dist-info/LICENSE,sha256=PhIEkitVi3ejgq56tt6sWoJIG_zmv82cjjd_aYPPGdI,1072
64
- folio_migration_tools-1.9.0a4.dist-info/METADATA,sha256=d0X2DDsYyC0_We_jm13ohilfXLQ_ujWVXejh5WThOis,7318
65
- folio_migration_tools-1.9.0a4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
- folio_migration_tools-1.9.0a4.dist-info/RECORD,,
63
+ folio_migration_tools-1.9.0a6.dist-info/LICENSE,sha256=PhIEkitVi3ejgq56tt6sWoJIG_zmv82cjjd_aYPPGdI,1072
64
+ folio_migration_tools-1.9.0a6.dist-info/METADATA,sha256=lS2KczFVuB7qYW2ToxgUlOyTrj40iq861jbtPksN_Pc,7330
65
+ folio_migration_tools-1.9.0a6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
66
+ folio_migration_tools-1.9.0a6.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any