folio-data-import 0.2.7__tar.gz → 0.2.8rc2__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 folio-data-import might be problematic. Click here for more details.
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/PKG-INFO +1 -1
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/pyproject.toml +1 -1
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/UserImport.py +68 -10
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/LICENSE +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/README.md +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/MARCDataImport.py +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/__init__.py +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/__main__.py +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/marc_preprocessors/__init__.py +0 -0
- {folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/marc_preprocessors/_preprocessors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "folio_data_import"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.8rc2"
|
|
4
4
|
description = "A python module to interact with the data importing capabilities of the open-source FOLIO ILS"
|
|
5
5
|
authors = ["Brooks Travis <brooks.travis@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -5,6 +5,7 @@ import getpass
|
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
7
|
import time
|
|
8
|
+
import uuid
|
|
8
9
|
from datetime import datetime as dt
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import Tuple
|
|
@@ -94,6 +95,23 @@ class UserImporter: # noqa: R0902
|
|
|
94
95
|
"""
|
|
95
96
|
return {x[name]: x["id"] for x in folio_client.folio_get_all(endpoint, key)}
|
|
96
97
|
|
|
98
|
+
@staticmethod
|
|
99
|
+
def validate_uuid(uuid_string: str) -> bool:
|
|
100
|
+
"""
|
|
101
|
+
Validate a UUID string.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
uuid_string (str): The UUID string to validate.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
bool: True if the UUID is valid, otherwise False.
|
|
108
|
+
"""
|
|
109
|
+
try:
|
|
110
|
+
uuid.UUID(uuid_string)
|
|
111
|
+
return True
|
|
112
|
+
except ValueError:
|
|
113
|
+
return False
|
|
114
|
+
|
|
97
115
|
async def do_import(self) -> None:
|
|
98
116
|
"""
|
|
99
117
|
Main method to import users.
|
|
@@ -203,10 +221,20 @@ class UserImporter: # noqa: R0902
|
|
|
203
221
|
mapped_addresses = []
|
|
204
222
|
for address in addresses:
|
|
205
223
|
try:
|
|
206
|
-
|
|
207
|
-
address["addressTypeId"]
|
|
208
|
-
|
|
209
|
-
|
|
224
|
+
if (
|
|
225
|
+
self.validate_uuid(address["addressTypeId"])
|
|
226
|
+
and address["addressTypeId"] in self.address_type_map.values()
|
|
227
|
+
):
|
|
228
|
+
await self.logfile.write(
|
|
229
|
+
f"Row {line_number}: Address type {address['addressTypeId']} is a UUID, "
|
|
230
|
+
f"skipping mapping\n"
|
|
231
|
+
)
|
|
232
|
+
mapped_addresses.append(address)
|
|
233
|
+
else:
|
|
234
|
+
address["addressTypeId"] = self.address_type_map[
|
|
235
|
+
address["addressTypeId"]
|
|
236
|
+
]
|
|
237
|
+
mapped_addresses.append(address)
|
|
210
238
|
except KeyError:
|
|
211
239
|
if address["addressTypeId"] not in self.address_type_map.values():
|
|
212
240
|
print(
|
|
@@ -232,7 +260,16 @@ class UserImporter: # noqa: R0902
|
|
|
232
260
|
None
|
|
233
261
|
"""
|
|
234
262
|
try:
|
|
235
|
-
|
|
263
|
+
if (
|
|
264
|
+
self.validate_uuid(user_obj["patronGroup"])
|
|
265
|
+
and user_obj["patronGroup"] in self.patron_group_map.values()
|
|
266
|
+
):
|
|
267
|
+
await self.logfile.write(
|
|
268
|
+
f"Row {line_number}: Patron group {user_obj['patronGroup']} is a UUID, "
|
|
269
|
+
f"skipping mapping\n"
|
|
270
|
+
)
|
|
271
|
+
else:
|
|
272
|
+
user_obj["patronGroup"] = self.patron_group_map[user_obj["patronGroup"]]
|
|
236
273
|
except KeyError:
|
|
237
274
|
if user_obj["patronGroup"] not in self.patron_group_map.values():
|
|
238
275
|
print(
|
|
@@ -259,7 +296,16 @@ class UserImporter: # noqa: R0902
|
|
|
259
296
|
mapped_departments = []
|
|
260
297
|
for department in user_obj.pop("departments", []):
|
|
261
298
|
try:
|
|
262
|
-
|
|
299
|
+
if (
|
|
300
|
+
self.validate_uuid(department)
|
|
301
|
+
and department in self.department_map.values()
|
|
302
|
+
):
|
|
303
|
+
await self.logfile.write(
|
|
304
|
+
f"Row {line_number}: Department {department} is a UUID, skipping mapping\n"
|
|
305
|
+
)
|
|
306
|
+
mapped_departments.append(department)
|
|
307
|
+
else:
|
|
308
|
+
mapped_departments.append(self.department_map[department])
|
|
263
309
|
except KeyError:
|
|
264
310
|
print(
|
|
265
311
|
f'Row {line_number}: Department "{department}" not found, ' # noqa: B907
|
|
@@ -493,7 +539,7 @@ class UserImporter: # noqa: R0902
|
|
|
493
539
|
and the existing PU object (existing_pu).
|
|
494
540
|
"""
|
|
495
541
|
rp_obj = user_obj.pop("requestPreference", {})
|
|
496
|
-
spu_obj = user_obj.pop("servicePointsUser")
|
|
542
|
+
spu_obj = user_obj.pop("servicePointsUser", {})
|
|
497
543
|
existing_user = await self.get_existing_user(user_obj)
|
|
498
544
|
if existing_user:
|
|
499
545
|
existing_rp = await self.get_existing_rp(user_obj, existing_user)
|
|
@@ -677,7 +723,13 @@ class UserImporter: # noqa: R0902
|
|
|
677
723
|
mapped_service_points = []
|
|
678
724
|
for sp in spu_obj.pop("servicePointsIds", []):
|
|
679
725
|
try:
|
|
680
|
-
|
|
726
|
+
if self.validate_uuid(sp) and sp in self.service_point_map.values():
|
|
727
|
+
await self.logfile.write(
|
|
728
|
+
f"Service point {sp} is a UUID, skipping mapping\n"
|
|
729
|
+
)
|
|
730
|
+
mapped_service_points.append(sp)
|
|
731
|
+
else:
|
|
732
|
+
mapped_service_points.append(self.service_point_map[sp])
|
|
681
733
|
except KeyError:
|
|
682
734
|
print(
|
|
683
735
|
f'Service point "{sp}" not found, excluding service point from user: '
|
|
@@ -688,7 +740,13 @@ class UserImporter: # noqa: R0902
|
|
|
688
740
|
if "defaultServicePointId" in spu_obj:
|
|
689
741
|
sp_code = spu_obj.pop('defaultServicePointId', '')
|
|
690
742
|
try:
|
|
691
|
-
|
|
743
|
+
if self.validate_uuid(sp_code) and sp_code in self.service_point_map.values():
|
|
744
|
+
await self.logfile.write(
|
|
745
|
+
f"Default service point {sp_code} is a UUID, skipping mapping\n"
|
|
746
|
+
)
|
|
747
|
+
mapped_sp_id = sp_code
|
|
748
|
+
else:
|
|
749
|
+
mapped_sp_id = self.service_point_map[sp_code]
|
|
692
750
|
if mapped_sp_id not in spu_obj.get('servicePointsIds', []):
|
|
693
751
|
print(
|
|
694
752
|
f'Default service point "{sp_code}" not found in assigned service points, '
|
|
@@ -711,7 +769,7 @@ class UserImporter: # noqa: R0902
|
|
|
711
769
|
existing_spu (dict): The existing service-points-user object, if it exists.
|
|
712
770
|
existing_user (dict): The existing user object associated with the spu_obj.
|
|
713
771
|
"""
|
|
714
|
-
if spu_obj
|
|
772
|
+
if spu_obj:
|
|
715
773
|
await self.map_service_points(spu_obj, existing_user)
|
|
716
774
|
if existing_spu:
|
|
717
775
|
await self.update_existing_spu(spu_obj, existing_spu)
|
|
File without changes
|
|
File without changes
|
{folio_data_import-0.2.7 → folio_data_import-0.2.8rc2}/src/folio_data_import/MARCDataImport.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|