folio-migration-tools 1.10.0b6__py3-none-any.whl → 1.10.1__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.
- folio_migration_tools/circulation_helper.py +6 -5
- folio_migration_tools/folder_structure.py +16 -3
- folio_migration_tools/helper.py +7 -6
- folio_migration_tools/holdings_helper.py +4 -3
- folio_migration_tools/i18n_cache.py +79 -0
- folio_migration_tools/mapper_base.py +7 -6
- folio_migration_tools/marc_rules_transformation/rules_mapper_base.py +10 -9
- folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py +3 -2
- folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py +6 -5
- folio_migration_tools/migration_report.py +17 -6
- folio_migration_tools/migration_tasks/batch_poster.py +5 -3
- folio_migration_tools/migration_tasks/bibs_transformer.py +4 -2
- folio_migration_tools/migration_tasks/courses_migrator.py +2 -0
- folio_migration_tools/migration_tasks/holdings_csv_transformer.py +11 -9
- folio_migration_tools/migration_tasks/holdings_marc_transformer.py +5 -3
- folio_migration_tools/migration_tasks/items_transformer.py +8 -4
- folio_migration_tools/migration_tasks/loans_migrator.py +21 -18
- folio_migration_tools/migration_tasks/manual_fee_fines_transformer.py +5 -3
- folio_migration_tools/migration_tasks/orders_transformer.py +6 -3
- folio_migration_tools/migration_tasks/organization_transformer.py +2 -0
- folio_migration_tools/migration_tasks/requests_migrator.py +12 -9
- folio_migration_tools/migration_tasks/reserves_migrator.py +7 -4
- folio_migration_tools/migration_tasks/user_transformer.py +7 -5
- {folio_migration_tools-1.10.0b6.dist-info → folio_migration_tools-1.10.1.dist-info}/METADATA +2 -1
- {folio_migration_tools-1.10.0b6.dist-info → folio_migration_tools-1.10.1.dist-info}/RECORD +27 -26
- {folio_migration_tools-1.10.0b6.dist-info → folio_migration_tools-1.10.1.dist-info}/WHEEL +0 -0
- {folio_migration_tools-1.10.0b6.dist-info → folio_migration_tools-1.10.1.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
|
-
|
|
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
|
-
|
|
361
|
+
i18n_t("Holdings transformation report"),
|
|
362
362
|
migration_report_file,
|
|
363
363
|
self.mapper.start_datetime,
|
|
364
364
|
)
|
|
@@ -368,6 +368,8 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
368
368
|
self.mapper.mapped_folio_fields,
|
|
369
369
|
self.mapper.mapped_legacy_fields,
|
|
370
370
|
)
|
|
371
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
372
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
371
373
|
logging.info("All done!")
|
|
372
374
|
self.clean_out_empty_logs()
|
|
373
375
|
|
|
@@ -393,7 +395,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
393
395
|
full_path = self.folder_structure.data_folder / "items" / file_def.file_name
|
|
394
396
|
with open(full_path, encoding="utf-8-sig") as records_file:
|
|
395
397
|
self.mapper.migration_report.add_general_statistics(
|
|
396
|
-
|
|
398
|
+
i18n_t("Number of files processed")
|
|
397
399
|
)
|
|
398
400
|
start = time.time()
|
|
399
401
|
records_processed = 0
|
|
@@ -412,7 +414,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
412
414
|
except Exception as excepion:
|
|
413
415
|
self.mapper.handle_generic_exception(idx, excepion)
|
|
414
416
|
self.mapper.migration_report.add_general_statistics(
|
|
415
|
-
|
|
417
|
+
i18n_t("Number of Legacy items in file")
|
|
416
418
|
)
|
|
417
419
|
if idx > 1 and idx % 10000 == 0:
|
|
418
420
|
elapsed = idx / (time.time() - start)
|
|
@@ -481,7 +483,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
481
483
|
self.holdings[bw_key] = incoming_holding
|
|
482
484
|
self.mapper.create_and_write_boundwith_part(legacy_item_id, incoming_holding["id"])
|
|
483
485
|
self.mapper.migration_report.add_general_statistics(
|
|
484
|
-
|
|
486
|
+
i18n_t("Unique BW Holdings created from Items")
|
|
485
487
|
)
|
|
486
488
|
else:
|
|
487
489
|
self.merge_holding(bw_key, incoming_holding)
|
|
@@ -492,7 +494,7 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
492
494
|
legacy_item_id, self.holdings[bw_key], self.object_type
|
|
493
495
|
)
|
|
494
496
|
self.mapper.migration_report.add_general_statistics(
|
|
495
|
-
|
|
497
|
+
i18n_t("BW Items found tied to previously created BW Holdings")
|
|
496
498
|
)
|
|
497
499
|
else:
|
|
498
500
|
# Regular holding. Merge according to criteria
|
|
@@ -504,12 +506,12 @@ class HoldingsCsvTransformer(MigrationTaskBase):
|
|
|
504
506
|
)
|
|
505
507
|
if self.holdings.get(new_holding_key, None):
|
|
506
508
|
self.mapper.migration_report.add_general_statistics(
|
|
507
|
-
|
|
509
|
+
i18n_t("Holdings already created from Item")
|
|
508
510
|
)
|
|
509
511
|
self.merge_holding(new_holding_key, incoming_holding)
|
|
510
512
|
else:
|
|
511
513
|
self.mapper.migration_report.add_general_statistics(
|
|
512
|
-
|
|
514
|
+
i18n_t("Unique Holdings created from Items")
|
|
513
515
|
)
|
|
514
516
|
self.holdings[new_holding_key] = incoming_holding
|
|
515
517
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
353
|
+
i18n_t("Bibliographic records transformation report"),
|
|
354
354
|
report_file,
|
|
355
355
|
self.start_datetime,
|
|
356
356
|
)
|
|
@@ -360,6 +360,8 @@ class HoldingsMarcTransformer(MigrationTaskBase):
|
|
|
360
360
|
self.mapper.mapped_folio_fields,
|
|
361
361
|
self.mapper.mapped_legacy_fields,
|
|
362
362
|
)
|
|
363
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
364
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
363
365
|
|
|
364
366
|
logging.info(
|
|
365
367
|
"Done. Transformation report written to %s",
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
474
|
+
i18n_t("Item transformation report"),
|
|
473
475
|
migration_report_file,
|
|
474
476
|
self.mapper.start_datetime,
|
|
475
477
|
)
|
|
@@ -479,5 +481,7 @@ class ItemsTransformer(MigrationTaskBase):
|
|
|
479
481
|
self.mapper.mapped_folio_fields,
|
|
480
482
|
self.mapper.mapped_legacy_fields,
|
|
481
483
|
)
|
|
484
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
485
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
482
486
|
self.clean_out_empty_logs()
|
|
483
487
|
logging.info("All done!")
|
|
@@ -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
|
-
|
|
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",
|
|
237
|
-
self.migration_report.add_general_statistics(
|
|
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",
|
|
244
|
-
self.migration_report.add_general_statistics(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
273
|
+
self.migration_report.add_general_statistics(i18n_t("Failed loans"))
|
|
273
274
|
self.migration_report.add(
|
|
274
275
|
"Details",
|
|
275
|
-
|
|
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
|
-
|
|
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(
|
|
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,8 +312,10 @@ 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
|
-
|
|
315
|
+
i18n_t("Loans migration report"), report_file, self.start_datetime
|
|
315
316
|
)
|
|
317
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
318
|
+
self.migration_report.write_json_report(raw_report_file)
|
|
316
319
|
self.clean_out_empty_logs()
|
|
317
320
|
|
|
318
321
|
def write_failed_loans_to_file(self):
|
|
@@ -351,7 +354,7 @@ class LoansMigrator(MigrationTaskBase):
|
|
|
351
354
|
)
|
|
352
355
|
if has_item_barcode and has_patron_barcode and has_proxy_barcode:
|
|
353
356
|
self.migration_report.add_general_statistics(
|
|
354
|
-
|
|
357
|
+
i18n_t("Loans verified against migrated user and item")
|
|
355
358
|
)
|
|
356
359
|
yield loan
|
|
357
360
|
else:
|
|
@@ -360,9 +363,9 @@ class LoansMigrator(MigrationTaskBase):
|
|
|
360
363
|
self.migration_report.add_general_statistics(i18n.t("Failed loans"))
|
|
361
364
|
self.migration_report.add(
|
|
362
365
|
"DiscardedLoans",
|
|
363
|
-
|
|
366
|
+
i18n_t("Loans discarded. Had migrated item barcode")
|
|
364
367
|
+ f": {has_item_barcode}. "
|
|
365
|
-
+
|
|
368
|
+
+ i18n_t("Had migrated user barcode")
|
|
366
369
|
+ f": {has_patron_barcode}"
|
|
367
370
|
+ f": {has_proxy_barcode}",
|
|
368
371
|
)
|
|
@@ -399,9 +402,9 @@ class LoansMigrator(MigrationTaskBase):
|
|
|
399
402
|
if any(legacy_loan.errors):
|
|
400
403
|
num_bad += 1
|
|
401
404
|
self.migration_report.add_general_statistics(
|
|
402
|
-
|
|
405
|
+
i18n_t("Loans failed pre-validation")
|
|
403
406
|
)
|
|
404
|
-
self.migration_report.add_general_statistics(
|
|
407
|
+
self.migration_report.add_general_statistics(i18n_t("Failed loans"))
|
|
405
408
|
for error in legacy_loan.errors:
|
|
406
409
|
self.migration_report.add("DiscardedLoans", f"{error[0]} - {error[1]}")
|
|
407
410
|
# Add this loan to failed loans for later correction and re-run.
|
|
@@ -412,7 +415,7 @@ class LoansMigrator(MigrationTaskBase):
|
|
|
412
415
|
results.append(legacy_loan)
|
|
413
416
|
except TransformationRecordFailedError as trfe:
|
|
414
417
|
num_bad += 1
|
|
415
|
-
self.migration_report.add_general_statistics(
|
|
418
|
+
self.migration_report.add_general_statistics(i18n_t("Loans failed pre-validation"))
|
|
416
419
|
self.migration_report.add(
|
|
417
420
|
"DiscardedLoans",
|
|
418
421
|
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
|
-
|
|
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
|
-
|
|
175
|
+
i18n_t("Manual fee/fine transformation report"),
|
|
176
176
|
migration_report_file,
|
|
177
177
|
self.start_datetime,
|
|
178
178
|
)
|
|
@@ -183,5 +183,7 @@ class ManualFeeFinesTransformer(MigrationTaskBase):
|
|
|
183
183
|
self.mapper.mapped_folio_fields,
|
|
184
184
|
self.mapper.mapped_legacy_fields,
|
|
185
185
|
)
|
|
186
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
187
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
186
188
|
|
|
187
189
|
self.clean_out_empty_logs()
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
320
|
+
i18n_t("Pruchase Orders and Purchase Order Lines Transformation Report"),
|
|
320
321
|
migration_report_file,
|
|
321
322
|
self.start_datetime,
|
|
322
323
|
)
|
|
@@ -327,6 +328,8 @@ class OrdersTransformer(MigrationTaskBase):
|
|
|
327
328
|
self.mapper.mapped_folio_fields,
|
|
328
329
|
self.mapper.mapped_legacy_fields,
|
|
329
330
|
)
|
|
331
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
332
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
330
333
|
logging.info("All done!")
|
|
331
334
|
|
|
332
335
|
def merge_into_orders_with_embedded_pols(self, folio_rec, results_file):
|
|
@@ -299,6 +299,8 @@ class OrganizationTransformer(MigrationTaskBase):
|
|
|
299
299
|
self.mapper.save_id_map_file(
|
|
300
300
|
self.folder_structure.organizations_id_map_path, self.organizations_id_map
|
|
301
301
|
)
|
|
302
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
303
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
302
304
|
self.clean_out_empty_logs()
|
|
303
305
|
|
|
304
306
|
logging.info("All done!")
|
|
@@ -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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
210
|
+
i18n_t("Successfully migrated requests")
|
|
210
211
|
)
|
|
211
212
|
else:
|
|
212
213
|
self.migration_report.add_general_statistics(
|
|
213
|
-
|
|
214
|
+
i18n_t("Unsuccessfully migrated requests")
|
|
214
215
|
)
|
|
215
216
|
self.failed_requests.add(legacy_request)
|
|
216
217
|
if num_requests == 1:
|
|
@@ -233,8 +234,10 @@ 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
|
-
|
|
237
|
+
i18n_t("Requests migration report"), report_file, self.start_datetime
|
|
237
238
|
)
|
|
239
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
240
|
+
self.migration_report.write_json_report(raw_report_file)
|
|
238
241
|
self.clean_out_empty_logs()
|
|
239
242
|
|
|
240
243
|
def write_failed_request_to_file(self):
|
|
@@ -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(
|
|
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
|
-
|
|
111
|
+
i18n_t("Successfully posted reserves")
|
|
111
112
|
)
|
|
112
113
|
else:
|
|
113
|
-
self.migration_report.add_general_statistics(
|
|
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,8 +124,10 @@ 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
|
-
|
|
127
|
+
i18n_t("Reserves migration report"), report_file, self.start_datetime
|
|
127
128
|
)
|
|
129
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
130
|
+
self.migration_report.write_json_report(raw_report_file)
|
|
128
131
|
self.clean_out_empty_logs()
|
|
129
132
|
|
|
130
133
|
def write_failed_reserves_to_file(self):
|
|
@@ -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,
|
|
@@ -218,13 +218,13 @@ class UserTransformer(MigrationTaskBase):
|
|
|
218
218
|
logging.info("## First FOLIO user")
|
|
219
219
|
logging.info(json.dumps(folio_user, indent=4, sort_keys=True))
|
|
220
220
|
self.mapper.migration_report.add_general_statistics(
|
|
221
|
-
|
|
221
|
+
i18n_t("Successful user transformations")
|
|
222
222
|
)
|
|
223
223
|
if num_users % 1000 == 0:
|
|
224
224
|
logging.info(f"{num_users} users processed.")
|
|
225
225
|
except TransformationRecordFailedError as tre:
|
|
226
226
|
self.mapper.migration_report.add_general_statistics(
|
|
227
|
-
|
|
227
|
+
i18n_t("Records failed")
|
|
228
228
|
)
|
|
229
229
|
Helper.log_data_issue(tre.index_or_id, tre.message, tre.data_value)
|
|
230
230
|
logging.error(tre)
|
|
@@ -241,7 +241,7 @@ class UserTransformer(MigrationTaskBase):
|
|
|
241
241
|
logging.error(num_users)
|
|
242
242
|
logging.error(json.dumps(legacy_user))
|
|
243
243
|
self.mapper.migration_report.add_general_statistics(
|
|
244
|
-
|
|
244
|
+
i18n_t("Failed user transformations")
|
|
245
245
|
)
|
|
246
246
|
logging.error(ee, exc_info=True)
|
|
247
247
|
|
|
@@ -255,7 +255,7 @@ class UserTransformer(MigrationTaskBase):
|
|
|
255
255
|
self.extradata_writer.flush()
|
|
256
256
|
with open(self.folder_structure.migration_reports_file, "w") as migration_report_file:
|
|
257
257
|
self.mapper.migration_report.write_migration_report(
|
|
258
|
-
|
|
258
|
+
i18n_t("Users transformation report"),
|
|
259
259
|
migration_report_file,
|
|
260
260
|
self.mapper.start_datetime,
|
|
261
261
|
)
|
|
@@ -265,6 +265,8 @@ class UserTransformer(MigrationTaskBase):
|
|
|
265
265
|
self.mapper.mapped_folio_fields,
|
|
266
266
|
self.mapper.mapped_legacy_fields,
|
|
267
267
|
)
|
|
268
|
+
with open(self.folder_structure.migration_reports_raw_file, "w") as raw_report_file:
|
|
269
|
+
self.mapper.migration_report.write_json_report(raw_report_file)
|
|
268
270
|
logging.info("All done!")
|
|
269
271
|
self.clean_out_empty_logs()
|
|
270
272
|
|
{folio_migration_tools-1.10.0b6.dist-info → folio_migration_tools-1.10.1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: folio-migration-tools
|
|
3
|
-
Version: 1.10.
|
|
3
|
+
Version: 1.10.1
|
|
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
|
|
@@ -18,6 +18,7 @@ Requires-Dist: deepdiff>=6.2.3,<7.0.0
|
|
|
18
18
|
Requires-Dist: pyaml>=21.10.1,<22.0.0
|
|
19
19
|
Requires-Dist: python-i18n>=0.3.9,<1.0.0
|
|
20
20
|
Requires-Dist: art>=6.5,<7.0
|
|
21
|
+
Requires-Dist: folio-data-import>=0.5.0,<0.6.0
|
|
21
22
|
Requires-Python: >=3.10, <4.0
|
|
22
23
|
Project-URL: Documentation, https://folio-migration-tools.readthedocs.io/en/latest/
|
|
23
24
|
Project-URL: Homepage, https://github.com/folio-fse/folio_migration_tools
|