folio-migration-tools 1.10.0b4__py3-none-any.whl → 1.10.0b7__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.
Files changed (27) hide show
  1. folio_migration_tools/circulation_helper.py +6 -5
  2. folio_migration_tools/folder_structure.py +16 -3
  3. folio_migration_tools/helper.py +7 -6
  4. folio_migration_tools/holdings_helper.py +4 -3
  5. folio_migration_tools/i18n_cache.py +79 -0
  6. folio_migration_tools/mapper_base.py +7 -6
  7. folio_migration_tools/mapping_file_transformation/user_mapper.py +4 -0
  8. folio_migration_tools/marc_rules_transformation/rules_mapper_base.py +10 -9
  9. folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py +3 -2
  10. folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py +6 -5
  11. folio_migration_tools/migration_report.py +17 -6
  12. folio_migration_tools/migration_tasks/batch_poster.py +16 -16
  13. folio_migration_tools/migration_tasks/bibs_transformer.py +2 -2
  14. folio_migration_tools/migration_tasks/holdings_csv_transformer.py +9 -9
  15. folio_migration_tools/migration_tasks/holdings_marc_transformer.py +3 -3
  16. folio_migration_tools/migration_tasks/items_transformer.py +6 -4
  17. folio_migration_tools/migration_tasks/loans_migrator.py +19 -18
  18. folio_migration_tools/migration_tasks/manual_fee_fines_transformer.py +3 -3
  19. folio_migration_tools/migration_tasks/migration_task_base.py +13 -5
  20. folio_migration_tools/migration_tasks/orders_transformer.py +4 -3
  21. folio_migration_tools/migration_tasks/requests_migrator.py +10 -9
  22. folio_migration_tools/migration_tasks/reserves_migrator.py +5 -4
  23. folio_migration_tools/migration_tasks/user_transformer.py +15 -5
  24. {folio_migration_tools-1.10.0b4.dist-info → folio_migration_tools-1.10.0b7.dist-info}/METADATA +1 -1
  25. {folio_migration_tools-1.10.0b4.dist-info → folio_migration_tools-1.10.0b7.dist-info}/RECORD +27 -26
  26. {folio_migration_tools-1.10.0b4.dist-info → folio_migration_tools-1.10.0b7.dist-info}/WHEEL +0 -0
  27. {folio_migration_tools-1.10.0b4.dist-info → folio_migration_tools-1.10.0b7.dist-info}/entry_points.txt +0 -0
@@ -7,7 +7,6 @@ import time
7
7
  import traceback
8
8
  from typing import Annotated, List, Optional
9
9
 
10
- import i18n
11
10
  from folio_uuid.folio_namespaces import FOLIONamespaces
12
11
  from httpx import HTTPError
13
12
  from pydantic import Field
@@ -18,6 +17,7 @@ from folio_migration_tools.custom_exceptions import (
18
17
  )
19
18
  from folio_migration_tools.helper import Helper
20
19
  from folio_migration_tools.holdings_helper import HoldingsHelper
20
+ from folio_migration_tools.i18n_cache import i18n_t
21
21
  from folio_migration_tools.library_configuration import (
22
22
  FileDefinition,
23
23
  HridHandling,
@@ -351,14 +351,14 @@ class HoldingsCsvTransformer(MigrationTaskBase):
351
351
  )
352
352
  Helper.write_to_file(holdings_file, holding)
353
353
  self.mapper.migration_report.add_general_statistics(
354
- i18n.t("Holdings Records Written to disk")
354
+ i18n_t("Holdings Records Written to disk")
355
355
  )
356
356
  self.mapper.save_id_map_file(
357
357
  self.folder_structure.holdings_id_map_path, self.holdings_id_map
358
358
  )
359
359
  with open(self.folder_structure.migration_reports_file, "w") as migration_report_file:
360
360
  self.mapper.migration_report.write_migration_report(
361
- i18n.t("Holdings transformation report"),
361
+ i18n_t("Holdings transformation report"),
362
362
  migration_report_file,
363
363
  self.mapper.start_datetime,
364
364
  )
@@ -393,7 +393,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
393
393
  full_path = self.folder_structure.data_folder / "items" / file_def.file_name
394
394
  with open(full_path, encoding="utf-8-sig") as records_file:
395
395
  self.mapper.migration_report.add_general_statistics(
396
- i18n.t("Number of files processed")
396
+ i18n_t("Number of files processed")
397
397
  )
398
398
  start = time.time()
399
399
  records_processed = 0
@@ -412,7 +412,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
412
412
  except Exception as excepion:
413
413
  self.mapper.handle_generic_exception(idx, excepion)
414
414
  self.mapper.migration_report.add_general_statistics(
415
- i18n.t("Number of Legacy items in file")
415
+ i18n_t("Number of Legacy items in file")
416
416
  )
417
417
  if idx > 1 and idx % 10000 == 0:
418
418
  elapsed = idx / (time.time() - start)
@@ -481,7 +481,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
481
481
  self.holdings[bw_key] = incoming_holding
482
482
  self.mapper.create_and_write_boundwith_part(legacy_item_id, incoming_holding["id"])
483
483
  self.mapper.migration_report.add_general_statistics(
484
- i18n.t("Unique BW Holdings created from Items")
484
+ i18n_t("Unique BW Holdings created from Items")
485
485
  )
486
486
  else:
487
487
  self.merge_holding(bw_key, incoming_holding)
@@ -492,7 +492,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
492
492
  legacy_item_id, self.holdings[bw_key], self.object_type
493
493
  )
494
494
  self.mapper.migration_report.add_general_statistics(
495
- i18n.t("BW Items found tied to previously created BW Holdings")
495
+ i18n_t("BW Items found tied to previously created BW Holdings")
496
496
  )
497
497
  else:
498
498
  # Regular holding. Merge according to criteria
@@ -504,12 +504,12 @@ class HoldingsCsvTransformer(MigrationTaskBase):
504
504
  )
505
505
  if self.holdings.get(new_holding_key, None):
506
506
  self.mapper.migration_report.add_general_statistics(
507
- i18n.t("Holdings already created from Item")
507
+ i18n_t("Holdings already created from Item")
508
508
  )
509
509
  self.merge_holding(new_holding_key, incoming_holding)
510
510
  else:
511
511
  self.mapper.migration_report.add_general_statistics(
512
- i18n.t("Unique Holdings created from Items")
512
+ i18n_t("Unique Holdings created from Items")
513
513
  )
514
514
  self.holdings[new_holding_key] = incoming_holding
515
515
 
@@ -3,12 +3,12 @@ import json
3
3
  import logging
4
4
  from typing import Annotated, List
5
5
 
6
- import i18n
7
6
  from folio_uuid.folio_namespaces import FOLIONamespaces
8
7
  from pydantic import Field
9
8
 
10
9
  from folio_migration_tools.custom_exceptions import TransformationProcessError
11
10
  from folio_migration_tools.helper import Helper
11
+ from folio_migration_tools.i18n_cache import i18n_t
12
12
  from folio_migration_tools.library_configuration import (
13
13
  FileDefinition,
14
14
  HridHandling,
@@ -269,7 +269,7 @@ class HoldingsMarcTransformer(MigrationTaskBase):
269
269
  except FileNotFoundError as fnfe:
270
270
  raise TransformationProcessError(
271
271
  "",
272
- i18n.t("Provided boundwith relationship file not found"),
272
+ i18n_t("Provided boundwith relationship file not found"),
273
273
  self.task_configuration.boundwith_relationship_file_path,
274
274
  ) from fnfe
275
275
 
@@ -350,7 +350,7 @@ class HoldingsMarcTransformer(MigrationTaskBase):
350
350
 
351
351
  with open(self.folder_structure.migration_reports_file, "w+") as report_file:
352
352
  self.mapper.migration_report.write_migration_report(
353
- i18n.t("Bibliographic records transformation report"),
353
+ i18n_t("Bibliographic records transformation report"),
354
354
  report_file,
355
355
  self.start_datetime,
356
356
  )
@@ -12,6 +12,8 @@ import i18n
12
12
  from folio_uuid.folio_namespaces import FOLIONamespaces
13
13
  from pydantic import Field
14
14
 
15
+ from folio_migration_tools.i18n_cache import i18n_t
16
+
15
17
  from folio_migration_tools.custom_exceptions import (
16
18
  TransformationProcessError,
17
19
  TransformationRecordFailedError,
@@ -335,7 +337,7 @@ class ItemsTransformer(MigrationTaskBase):
335
337
  records_in_file = 0
336
338
  with open(full_path, encoding="utf-8-sig") as records_file:
337
339
  self.mapper.migration_report.add_general_statistics(
338
- i18n.t("Number of files processed")
340
+ i18n_t("Number of files processed")
339
341
  )
340
342
  start = time.time()
341
343
  for idx, record in enumerate(self.mapper.get_objects(records_file, full_path)):
@@ -368,7 +370,7 @@ class ItemsTransformer(MigrationTaskBase):
368
370
  # TODO: turn this into a asynchronous task
369
371
  Helper.write_to_file(results_file, folio_rec)
370
372
  self.mapper.migration_report.add_general_statistics(
371
- i18n.t("Number of records written to disk")
373
+ i18n_t("Number of records written to disk")
372
374
  )
373
375
  self.mapper.report_folio_mapping(folio_rec, self.mapper.schema)
374
376
  except TransformationProcessError as process_error:
@@ -387,7 +389,7 @@ class ItemsTransformer(MigrationTaskBase):
387
389
  i18n.t("Number of Legacy items in %{container}", container=file_def),
388
390
  )
389
391
  self.mapper.migration_report.add_general_statistics(
390
- i18n.t("Number of Legacy items in total")
392
+ i18n_t("Number of Legacy items in total")
391
393
  )
392
394
  self.print_progress(idx, start)
393
395
  records_in_file = idx + 1
@@ -469,7 +471,7 @@ class ItemsTransformer(MigrationTaskBase):
469
471
  self.extradata_writer.flush()
470
472
  with open(self.folder_structure.migration_reports_file, "w") as migration_report_file:
471
473
  self.mapper.migration_report.write_migration_report(
472
- i18n.t("Item transformation report"),
474
+ i18n_t("Item transformation report"),
473
475
  migration_report_file,
474
476
  self.mapper.start_datetime,
475
477
  )
@@ -19,6 +19,7 @@ from art import tprint
19
19
  from folio_migration_tools.circulation_helper import CirculationHelper
20
20
  from folio_migration_tools.custom_exceptions import TransformationRecordFailedError
21
21
  from folio_migration_tools.helper import Helper
22
+ from folio_migration_tools.i18n_cache import i18n_t
22
23
  from folio_migration_tools.library_configuration import (
23
24
  FileDefinition,
24
25
  LibraryConfiguration,
@@ -205,7 +206,7 @@ class LoansMigrator(MigrationTaskBase):
205
206
  ):
206
207
  t0_migration = time.time()
207
208
  self.migration_report.add_general_statistics(
208
- i18n.t("Processed pre-validated loans")
209
+ i18n_t("Processed pre-validated loans")
209
210
  )
210
211
  try:
211
212
  self.checkout_single_loan(legacy_loan)
@@ -233,15 +234,15 @@ class LoansMigrator(MigrationTaskBase):
233
234
  res_checkout = self.circulation_helper.check_out_by_barcode(legacy_loan)
234
235
 
235
236
  if res_checkout.was_successful:
236
- self.migration_report.add("Details", i18n.t("Checked out on first try"))
237
- self.migration_report.add_general_statistics(i18n.t("Successfully checked out"))
237
+ self.migration_report.add("Details", i18n_t("Checked out on first try"))
238
+ self.migration_report.add_general_statistics(i18n_t("Successfully checked out"))
238
239
  self.set_renewal_count(legacy_loan, res_checkout)
239
240
  self.set_new_status(legacy_loan, res_checkout)
240
241
  elif res_checkout.should_be_retried:
241
242
  res_checkout2 = self.handle_checkout_failure(legacy_loan, res_checkout)
242
243
  if res_checkout2.was_successful and res_checkout2.folio_loan:
243
- self.migration_report.add("Details", i18n.t("Checked out on second try"))
244
- self.migration_report.add_general_statistics(i18n.t("Successfully checked out"))
244
+ self.migration_report.add("Details", i18n_t("Checked out on second try"))
245
+ self.migration_report.add_general_statistics(i18n_t("Successfully checked out"))
245
246
  logging.info("Checked out on second try")
246
247
  self.set_renewal_count(legacy_loan, res_checkout2)
247
248
  self.set_new_status(legacy_loan, res_checkout2)
@@ -256,7 +257,7 @@ class LoansMigrator(MigrationTaskBase):
256
257
  )
257
258
  else:
258
259
  self.failed[legacy_loan.item_barcode] = legacy_loan
259
- self.migration_report.add_general_statistics(i18n.t("Failed loans"))
260
+ self.migration_report.add_general_statistics(i18n_t("Failed loans"))
260
261
  logging.error("Failed on second try: %s", res_checkout2.error_message)
261
262
  self.migration_report.add(
262
263
  "Details",
@@ -264,21 +265,21 @@ class LoansMigrator(MigrationTaskBase):
264
265
  )
265
266
  raise TransformationRecordFailedError(
266
267
  f"Row {legacy_loan.row}",
267
- i18n.t("Loans failing during checkout, second try"),
268
+ i18n_t("Loans failing during checkout, second try"),
268
269
  json.dumps(legacy_loan.to_dict()),
269
270
  )
270
271
  elif not res_checkout.should_be_retried:
271
272
  logging.error("Failed first time. No retries: %s", res_checkout.error_message)
272
- self.migration_report.add_general_statistics(i18n.t("Failed loans"))
273
+ self.migration_report.add_general_statistics(i18n_t("Failed loans"))
273
274
  self.migration_report.add(
274
275
  "Details",
275
- i18n.t("Failed 1st time. No retries")
276
+ i18n_t("Failed 1st time. No retries")
276
277
  + f": {res_checkout.migration_report_message}",
277
278
  )
278
279
  self.failed[legacy_loan.item_barcode] = legacy_loan
279
280
  raise TransformationRecordFailedError(
280
281
  f"Row {legacy_loan.row}",
281
- i18n.t("Loans failing during checkout"),
282
+ i18n_t("Loans failing during checkout"),
282
283
  json.dumps(legacy_loan.to_dict()),
283
284
  )
284
285
 
@@ -300,7 +301,7 @@ class LoansMigrator(MigrationTaskBase):
300
301
  def set_renewal_count(self, legacy_loan: LegacyLoan, res_checkout: TransactionResult):
301
302
  if legacy_loan.renewal_count > 0:
302
303
  self.update_open_loan(res_checkout.folio_loan, legacy_loan)
303
- self.migration_report.add_general_statistics(i18n.t("Updated renewal count for loan"))
304
+ self.migration_report.add_general_statistics(i18n_t("Updated renewal count for loan"))
304
305
 
305
306
  def wrap_up(self):
306
307
  for k, v in self.failed.items():
@@ -311,7 +312,7 @@ class LoansMigrator(MigrationTaskBase):
311
312
 
312
313
  with open(self.folder_structure.migration_reports_file, "w+") as report_file:
313
314
  self.migration_report.write_migration_report(
314
- i18n.t("Loans migration report"), report_file, self.start_datetime
315
+ i18n_t("Loans migration report"), report_file, self.start_datetime
315
316
  )
316
317
  self.clean_out_empty_logs()
317
318
 
@@ -351,7 +352,7 @@ class LoansMigrator(MigrationTaskBase):
351
352
  )
352
353
  if has_item_barcode and has_patron_barcode and has_proxy_barcode:
353
354
  self.migration_report.add_general_statistics(
354
- i18n.t("Loans verified against migrated user and item")
355
+ i18n_t("Loans verified against migrated user and item")
355
356
  )
356
357
  yield loan
357
358
  else:
@@ -360,9 +361,9 @@ class LoansMigrator(MigrationTaskBase):
360
361
  self.migration_report.add_general_statistics(i18n.t("Failed loans"))
361
362
  self.migration_report.add(
362
363
  "DiscardedLoans",
363
- i18n.t("Loans discarded. Had migrated item barcode")
364
+ i18n_t("Loans discarded. Had migrated item barcode")
364
365
  + f": {has_item_barcode}. "
365
- + i18n.t("Had migrated user barcode")
366
+ + i18n_t("Had migrated user barcode")
366
367
  + f": {has_patron_barcode}"
367
368
  + f": {has_proxy_barcode}",
368
369
  )
@@ -399,9 +400,9 @@ class LoansMigrator(MigrationTaskBase):
399
400
  if any(legacy_loan.errors):
400
401
  num_bad += 1
401
402
  self.migration_report.add_general_statistics(
402
- i18n.t("Loans failed pre-validation")
403
+ i18n_t("Loans failed pre-validation")
403
404
  )
404
- self.migration_report.add_general_statistics(i18n.t("Failed loans"))
405
+ self.migration_report.add_general_statistics(i18n_t("Failed loans"))
405
406
  for error in legacy_loan.errors:
406
407
  self.migration_report.add("DiscardedLoans", f"{error[0]} - {error[1]}")
407
408
  # Add this loan to failed loans for later correction and re-run.
@@ -412,7 +413,7 @@ class LoansMigrator(MigrationTaskBase):
412
413
  results.append(legacy_loan)
413
414
  except TransformationRecordFailedError as trfe:
414
415
  num_bad += 1
415
- self.migration_report.add_general_statistics(i18n.t("Loans failed pre-validation"))
416
+ self.migration_report.add_general_statistics(i18n_t("Loans failed pre-validation"))
416
417
  self.migration_report.add(
417
418
  "DiscardedLoans",
418
419
  f"{trfe.message} - see data issues log",
@@ -6,7 +6,6 @@ import time
6
6
  import traceback
7
7
  from typing import List, Optional
8
8
 
9
- import i18n
10
9
  from folio_uuid.folio_namespaces import FOLIONamespaces
11
10
 
12
11
  from folio_migration_tools.custom_exceptions import (
@@ -15,6 +14,7 @@ from folio_migration_tools.custom_exceptions import (
15
14
  TransformationRecordFailedError,
16
15
  )
17
16
  from folio_migration_tools.helper import Helper
17
+ from folio_migration_tools.i18n_cache import i18n_t
18
18
  from folio_migration_tools.library_configuration import (
19
19
  FileDefinition,
20
20
  LibraryConfiguration,
@@ -118,7 +118,7 @@ class ManualFeeFinesTransformer(MigrationTaskBase):
118
118
  full_path = self.folder_structure.legacy_records_folder / file_def.file_name
119
119
  with open(full_path, encoding="utf-8-sig") as records_file:
120
120
  self.mapper.migration_report.add_general_statistics(
121
- i18n.t("Number of files processed")
121
+ i18n_t("Number of files processed")
122
122
  )
123
123
  start = time.time()
124
124
 
@@ -172,7 +172,7 @@ class ManualFeeFinesTransformer(MigrationTaskBase):
172
172
  self.folder_structure.migration_reports_file,
173
173
  )
174
174
  self.mapper.migration_report.write_migration_report(
175
- i18n.t("Manual fee/fine transformation report"),
175
+ i18n_t("Manual fee/fine transformation report"),
176
176
  migration_report_file,
177
177
  self.start_datetime,
178
178
  )
@@ -99,6 +99,7 @@ class MigrationTaskBase:
99
99
  raise NotImplementedError()
100
100
 
101
101
  def clean_out_empty_logs(self):
102
+ _close_handler(self.data_issue_file_handler)
102
103
  if (
103
104
  self.folder_structure.data_issue_file_path.is_file()
104
105
  and os.stat(self.folder_structure.data_issue_file_path).st_size == 0
@@ -260,13 +261,13 @@ class MigrationTaskBase:
260
261
 
261
262
  # Data issue file formatter
262
263
  data_issue_file_formatter = logging.Formatter("%(message)s")
263
- data_issue_file_handler = logging.FileHandler(
264
+ self.data_issue_file_handler = logging.FileHandler(
264
265
  filename=str(self.folder_structure.data_issue_file_path), mode="w"
265
266
  )
266
- data_issue_file_handler.addFilter(LevelFilter(26))
267
- data_issue_file_handler.setFormatter(data_issue_file_formatter)
268
- data_issue_file_handler.setLevel(26)
269
- logging.getLogger().addHandler(data_issue_file_handler)
267
+ self.data_issue_file_handler.addFilter(LevelFilter(26))
268
+ self.data_issue_file_handler.setFormatter(data_issue_file_formatter)
269
+ self.data_issue_file_handler.setLevel(26)
270
+ logging.getLogger().addHandler(self.data_issue_file_handler)
270
271
  logger.info("Logging set up")
271
272
 
272
273
  def setup_records_map(self, mapping_file_path):
@@ -553,3 +554,10 @@ class LevelFilter(logging.Filter):
553
554
 
554
555
  def filter(self, record):
555
556
  return record.levelno == self.level
557
+
558
+
559
+ def _close_handler(handler: logging.Handler | None):
560
+ if handler is None:
561
+ return
562
+ handler.flush()
563
+ handler.close()
@@ -16,6 +16,7 @@ from folio_migration_tools.custom_exceptions import (
16
16
  TransformationRecordFailedError,
17
17
  )
18
18
  from folio_migration_tools.helper import Helper
19
+ from folio_migration_tools.i18n_cache import i18n_t
19
20
  from folio_migration_tools.library_configuration import (
20
21
  FileDefinition,
21
22
  LibraryConfiguration,
@@ -234,7 +235,7 @@ class OrdersTransformer(MigrationTaskBase):
234
235
  open(self.folder_structure.created_objects_path, "w+") as results_file,
235
236
  ):
236
237
  self.mapper.migration_report.add_general_statistics(
237
- i18n.t("Number of files processed")
238
+ i18n_t("Number of files processed")
238
239
  )
239
240
  start = time.time()
240
241
  records_processed = 0
@@ -253,7 +254,7 @@ class OrdersTransformer(MigrationTaskBase):
253
254
  self.mapper.perform_additional_mapping(legacy_id, folio_rec)
254
255
 
255
256
  self.mapper.migration_report.add_general_statistics(
256
- i18n.t("TOTAL Purchase Order Lines created")
257
+ i18n_t("TOTAL Purchase Order Lines created")
257
258
  )
258
259
  self.mapper.report_folio_mapping(folio_rec, self.mapper.composite_order_schema)
259
260
  self.mapper.notes_mapper.map_notes(
@@ -316,7 +317,7 @@ class OrdersTransformer(MigrationTaskBase):
316
317
  self.folder_structure.migration_reports_file,
317
318
  )
318
319
  self.mapper.migration_report.write_migration_report(
319
- i18n.t("Pruchase Orders and Purchase Order Lines Transformation Report"),
320
+ i18n_t("Pruchase Orders and Purchase Order Lines Transformation Report"),
320
321
  migration_report_file,
321
322
  self.start_datetime,
322
323
  )
@@ -13,6 +13,7 @@ from zoneinfo import ZoneInfo
13
13
  from folio_migration_tools.circulation_helper import CirculationHelper
14
14
  from folio_migration_tools.custom_dict import InsensitiveDictReader
15
15
  from folio_migration_tools.helper import Helper
16
+ from folio_migration_tools.i18n_cache import i18n_t
16
17
  from folio_migration_tools.library_configuration import (
17
18
  FileDefinition,
18
19
  LibraryConfiguration,
@@ -147,7 +148,7 @@ class RequestsMigrator(MigrationTaskBase):
147
148
 
148
149
  def prepare_legacy_request(self, legacy_request: LegacyRequest):
149
150
  patron = self.circulation_helper.get_user_by_barcode(legacy_request.patron_barcode)
150
- self.migration_report.add_general_statistics(i18n.t("Patron lookups performed"))
151
+ self.migration_report.add_general_statistics(i18n_t("Patron lookups performed"))
151
152
 
152
153
  if not patron:
153
154
  logging.error(f"No user with barcode {legacy_request.patron_barcode} found in FOLIO")
@@ -157,18 +158,18 @@ class RequestsMigrator(MigrationTaskBase):
157
158
  f"{legacy_request.patron_barcode}",
158
159
  )
159
160
  self.migration_report.add_general_statistics(
160
- i18n.t("No user with barcode found in FOLIO")
161
+ i18n_t("No user with barcode found in FOLIO")
161
162
  )
162
163
  self.failed_requests.add(legacy_request)
163
164
  return False, legacy_request
164
165
  legacy_request.patron_id = patron.get("id")
165
166
 
166
167
  item = self.circulation_helper.get_item_by_barcode(legacy_request.item_barcode)
167
- self.migration_report.add_general_statistics(i18n.t("Item lookups performed"))
168
+ self.migration_report.add_general_statistics(i18n_t("Item lookups performed"))
168
169
  if not item:
169
170
  logging.error(f"No item with barcode {legacy_request.item_barcode} found in FOLIO")
170
171
  self.migration_report.add_general_statistics(
171
- i18n.t("No item with barcode found in FOLIO")
172
+ i18n_t("No item with barcode found in FOLIO")
172
173
  )
173
174
  Helper.log_data_issue(
174
175
  f"{legacy_request.item_barcode}",
@@ -178,7 +179,7 @@ class RequestsMigrator(MigrationTaskBase):
178
179
  self.failed_requests.add(legacy_request)
179
180
  return False, legacy_request
180
181
  holding = self.circulation_helper.get_holding_by_uuid(item.get("holdingsRecordId"))
181
- self.migration_report.add_general_statistics(i18n.t("Holdings lookups performed"))
182
+ self.migration_report.add_general_statistics(i18n_t("Holdings lookups performed"))
182
183
  legacy_request.item_id = item.get("id")
183
184
  legacy_request.holdings_record_id = item.get("holdingsRecordId")
184
185
  legacy_request.instance_id = holding.get("instanceId")
@@ -186,7 +187,7 @@ class RequestsMigrator(MigrationTaskBase):
186
187
  legacy_request.request_type = "Page"
187
188
  logging.info(f"Setting request to Page, since the status is {item['status']['name']}")
188
189
  self.migration_report.add_general_statistics(
189
- i18n.t("Valid, prepared requests, ready for posting")
190
+ i18n_t("Valid, prepared requests, ready for posting")
190
191
  )
191
192
  return True, legacy_request
192
193
 
@@ -206,11 +207,11 @@ class RequestsMigrator(MigrationTaskBase):
206
207
  self.folio_client, legacy_request, self.migration_report
207
208
  ):
208
209
  self.migration_report.add_general_statistics(
209
- i18n.t("Successfully migrated requests")
210
+ i18n_t("Successfully migrated requests")
210
211
  )
211
212
  else:
212
213
  self.migration_report.add_general_statistics(
213
- i18n.t("Unsuccessfully migrated requests")
214
+ i18n_t("Unsuccessfully migrated requests")
214
215
  )
215
216
  self.failed_requests.add(legacy_request)
216
217
  if num_requests == 1:
@@ -233,7 +234,7 @@ class RequestsMigrator(MigrationTaskBase):
233
234
 
234
235
  with open(self.folder_structure.migration_reports_file, "w+") as report_file:
235
236
  self.migration_report.write_migration_report(
236
- i18n.t("Requests migration report"), report_file, self.start_datetime
237
+ i18n_t("Requests migration report"), report_file, self.start_datetime
237
238
  )
238
239
  self.clean_out_empty_logs()
239
240
 
@@ -14,6 +14,7 @@ from folio_uuid.folio_namespaces import FOLIONamespaces
14
14
 
15
15
  from folio_migration_tools.custom_dict import InsensitiveDictReader
16
16
  from folio_migration_tools.custom_exceptions import TransformationProcessError
17
+ from folio_migration_tools.i18n_cache import i18n_t
17
18
  from folio_migration_tools.library_configuration import (
18
19
  FileDefinition,
19
20
  LibraryConfiguration,
@@ -90,7 +91,7 @@ class ReservesMigrator(MigrationTaskBase):
90
91
  logging.info("Starting")
91
92
  for num_reserves, legacy_reserve in enumerate(self.valid_reserves, start=1):
92
93
  t0_migration = time.time()
93
- self.migration_report.add_general_statistics(i18n.t("Processed reserves"))
94
+ self.migration_report.add_general_statistics(i18n_t("Processed reserves"))
94
95
  try:
95
96
  self.post_single_reserve(legacy_reserve)
96
97
  except Exception as ee:
@@ -107,10 +108,10 @@ class ReservesMigrator(MigrationTaskBase):
107
108
  path, legacy_reserve.to_dict(), "POST", i18n.t("Posted reserves")
108
109
  ):
109
110
  self.migration_report.add_general_statistics(
110
- i18n.t("Successfully posted reserves")
111
+ i18n_t("Successfully posted reserves")
111
112
  )
112
113
  else:
113
- self.migration_report.add_general_statistics(i18n.t("Failure to post reserve"))
114
+ self.migration_report.add_general_statistics(i18n_t("Failure to post reserve"))
114
115
  except Exception as ee:
115
116
  logging.error(ee)
116
117
 
@@ -123,7 +124,7 @@ class ReservesMigrator(MigrationTaskBase):
123
124
 
124
125
  with open(self.folder_structure.migration_reports_file, "w+") as report_file:
125
126
  self.migration_report.write_migration_report(
126
- i18n.t("Reserves migration report"), report_file, self.start_datetime
127
+ i18n_t("Reserves migration report"), report_file, self.start_datetime
127
128
  )
128
129
  self.clean_out_empty_logs()
129
130
 
@@ -4,7 +4,6 @@ import sys
4
4
  from typing import Optional, Annotated
5
5
  from pydantic import Field
6
6
 
7
- import i18n
8
7
  from folio_uuid.folio_namespaces import FOLIONamespaces
9
8
  from art import tprint
10
9
 
@@ -13,6 +12,7 @@ from folio_migration_tools.custom_exceptions import (
13
12
  TransformationRecordFailedError,
14
13
  )
15
14
  from folio_migration_tools.helper import Helper
15
+ from folio_migration_tools.i18n_cache import i18n_t
16
16
  from folio_migration_tools.library_configuration import (
17
17
  FileDefinition,
18
18
  LibraryConfiguration,
@@ -101,6 +101,16 @@ class UserTransformer(MigrationTaskBase):
101
101
  ),
102
102
  ),
103
103
  ] = False
104
+ remove_username: Annotated[
105
+ Optional[bool],
106
+ Field(
107
+ title="Remove username",
108
+ description=(
109
+ "Specify whether to remove username. Resulting objects are not compatible with"
110
+ " the mod-user-import. Optional, by default is False"
111
+ ),
112
+ ),
113
+ ] = False
104
114
 
105
115
  @staticmethod
106
116
  def get_object_type() -> FOLIONamespaces:
@@ -208,13 +218,13 @@ class UserTransformer(MigrationTaskBase):
208
218
  logging.info("## First FOLIO user")
209
219
  logging.info(json.dumps(folio_user, indent=4, sort_keys=True))
210
220
  self.mapper.migration_report.add_general_statistics(
211
- i18n.t("Successful user transformations")
221
+ i18n_t("Successful user transformations")
212
222
  )
213
223
  if num_users % 1000 == 0:
214
224
  logging.info(f"{num_users} users processed.")
215
225
  except TransformationRecordFailedError as tre:
216
226
  self.mapper.migration_report.add_general_statistics(
217
- i18n.t("Records failed")
227
+ i18n_t("Records failed")
218
228
  )
219
229
  Helper.log_data_issue(tre.index_or_id, tre.message, tre.data_value)
220
230
  logging.error(tre)
@@ -231,7 +241,7 @@ class UserTransformer(MigrationTaskBase):
231
241
  logging.error(num_users)
232
242
  logging.error(json.dumps(legacy_user))
233
243
  self.mapper.migration_report.add_general_statistics(
234
- i18n.t("Failed user transformations")
244
+ i18n_t("Failed user transformations")
235
245
  )
236
246
  logging.error(ee, exc_info=True)
237
247
 
@@ -245,7 +255,7 @@ class UserTransformer(MigrationTaskBase):
245
255
  self.extradata_writer.flush()
246
256
  with open(self.folder_structure.migration_reports_file, "w") as migration_report_file:
247
257
  self.mapper.migration_report.write_migration_report(
248
- i18n.t("Users transformation report"),
258
+ i18n_t("Users transformation report"),
249
259
  migration_report_file,
250
260
  self.mapper.start_datetime,
251
261
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: folio-migration-tools
3
- Version: 1.10.0b4
3
+ Version: 1.10.0b7
4
4
  Summary: A tool allowing you to migrate data from legacy ILS:s (Library systems) into FOLIO LSP
5
5
  Keywords: FOLIO,ILS,LSP,Library Systems,MARC21,Library data
6
6
  Author: Theodor Tolstoy, Lisa Sjögren, Brooks Travis, Jeremy Nelson, Clinton Bradford