folio-data-import 0.2.6__tar.gz → 0.2.7__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.6 → folio_data_import-0.2.7}/PKG-INFO +23 -4
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/README.md +22 -3
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/pyproject.toml +1 -1
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/UserImport.py +8 -5
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/LICENSE +0 -0
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/MARCDataImport.py +0 -0
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/__init__.py +0 -0
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/__main__.py +0 -0
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/marc_preprocessors/__init__.py +0 -0
- {folio_data_import-0.2.6 → folio_data_import-0.2.7}/src/folio_data_import/marc_preprocessors/_preprocessors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: folio_data_import
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A python module to interact with the data importing capabilities of the open-source FOLIO ILS
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Brooks Travis
|
|
@@ -102,11 +102,30 @@ When this package is installed via PyPI or using `poetry install` from this repo
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
|
-
|
|
105
|
+
#### Matching Existing Users
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Unlike mod-user-import, this importer does not require `externalSystemId` as the match point for your objects. If the user objects have `id` values, that will be used, falling back to `externalSystemId`. However, you can also specify `username` or `barcode` as the match point if desired, using the `--user_match_key` argument.
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
#### Preferred Contact Type Mapping
|
|
110
|
+
|
|
111
|
+
Another point of departure from the behavior of `mod-user-import` is the handling of `preferredContactTypeId`. This importer will accept either the `"001", "002", "003"...` values stored by the FOLIO, or the human-friendly strings used by `mod-user-import` (`"mail", "email", "text", "phone", "mobile"`). It will also __*set a customizable default for all users that do not otherwise have a valid value specified*__ (using `--default_preferred_contact_type`), unless a (valid) value is already present in the user record being updated.
|
|
112
|
+
|
|
113
|
+
#### Field Protection (*experimental*)
|
|
114
|
+
|
|
115
|
+
This script offers a rudimentary field protection implementation using custom fields. To enable this functionality, create a text custom field that has the field name `protectedFields`. In this field, you ca specify a comma-separated list of User schema field names, using dot-notation for nested fields. This protection should support all standard fields except addresses within `personal.addresses`. If you include `personal.addresses` in a user record, any existing addresses will be replaced by the new values.
|
|
116
|
+
|
|
117
|
+
##### Example
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
{
|
|
121
|
+
"protectedFields": "customFields.protectedFields,personal.preferredFirstName,barcode,personal.telephone,personal.addresses"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Would result in `preferredFirstName`, `barcode`, and `telephone` remaining unchanged, regardless of the contents of the incoming records.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
#### How to use:
|
|
110
129
|
1. Generate a JSON lines (one JSON object per line) file of FOLIO user objects in the style of [mod-user-import](https://github.com/folio-org/mod-user-import)
|
|
111
130
|
2. Run the script and specify the required arguments (and any desired optional arguments), including the path to your file of user objects
|
|
112
131
|
|
|
@@ -72,11 +72,30 @@ When this package is installed via PyPI or using `poetry install` from this repo
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
|
-
|
|
75
|
+
#### Matching Existing Users
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
Unlike mod-user-import, this importer does not require `externalSystemId` as the match point for your objects. If the user objects have `id` values, that will be used, falling back to `externalSystemId`. However, you can also specify `username` or `barcode` as the match point if desired, using the `--user_match_key` argument.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
#### Preferred Contact Type Mapping
|
|
80
|
+
|
|
81
|
+
Another point of departure from the behavior of `mod-user-import` is the handling of `preferredContactTypeId`. This importer will accept either the `"001", "002", "003"...` values stored by the FOLIO, or the human-friendly strings used by `mod-user-import` (`"mail", "email", "text", "phone", "mobile"`). It will also __*set a customizable default for all users that do not otherwise have a valid value specified*__ (using `--default_preferred_contact_type`), unless a (valid) value is already present in the user record being updated.
|
|
82
|
+
|
|
83
|
+
#### Field Protection (*experimental*)
|
|
84
|
+
|
|
85
|
+
This script offers a rudimentary field protection implementation using custom fields. To enable this functionality, create a text custom field that has the field name `protectedFields`. In this field, you ca specify a comma-separated list of User schema field names, using dot-notation for nested fields. This protection should support all standard fields except addresses within `personal.addresses`. If you include `personal.addresses` in a user record, any existing addresses will be replaced by the new values.
|
|
86
|
+
|
|
87
|
+
##### Example
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
{
|
|
91
|
+
"protectedFields": "customFields.protectedFields,personal.preferredFirstName,barcode,personal.telephone,personal.addresses"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Would result in `preferredFirstName`, `barcode`, and `telephone` remaining unchanged, regardless of the contents of the incoming records.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
#### How to use:
|
|
80
99
|
1. Generate a JSON lines (one JSON object per line) file of FOLIO user objects in the style of [mod-user-import](https://github.com/folio-org/mod-user-import)
|
|
81
100
|
2. Run the script and specify the required arguments (and any desired optional arguments), including the path to your file of user objects
|
|
82
101
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "folio_data_import"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.7"
|
|
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"
|
|
@@ -41,12 +41,12 @@ class UserImporter: # noqa: R0902
|
|
|
41
41
|
self,
|
|
42
42
|
folio_client: folioclient.FolioClient,
|
|
43
43
|
library_name: str,
|
|
44
|
-
user_file_path: Path,
|
|
45
44
|
batch_size: int,
|
|
46
45
|
limit_simultaneous_requests: asyncio.Semaphore,
|
|
47
46
|
logfile: AsyncTextIOWrapper,
|
|
48
47
|
errorfile: AsyncTextIOWrapper,
|
|
49
48
|
http_client: httpx.AsyncClient,
|
|
49
|
+
user_file_path: Path = None,
|
|
50
50
|
user_match_key: str = "externalSystemId",
|
|
51
51
|
only_update_present_fields: bool = False,
|
|
52
52
|
default_preferred_contact_type: str = "002",
|
|
@@ -100,8 +100,11 @@ class UserImporter: # noqa: R0902
|
|
|
100
100
|
|
|
101
101
|
This method triggers the process of importing users by calling the `process_file` method.
|
|
102
102
|
"""
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
if self.user_file_path:
|
|
104
|
+
with open(self.user_file_path, "r", encoding="utf-8") as openfile:
|
|
105
|
+
await self.process_file(openfile)
|
|
106
|
+
else:
|
|
107
|
+
raise FileNotFoundError("No user objects file provided")
|
|
105
108
|
|
|
106
109
|
async def get_existing_user(self, user_obj) -> dict:
|
|
107
110
|
"""
|
|
@@ -781,7 +784,7 @@ class UserImporter: # noqa: R0902
|
|
|
781
784
|
Process the user object file.
|
|
782
785
|
|
|
783
786
|
Args:
|
|
784
|
-
openfile: The file object to process.
|
|
787
|
+
openfile: The file or file-like object to process.
|
|
785
788
|
"""
|
|
786
789
|
tasks = []
|
|
787
790
|
for line_number, user in enumerate(openfile):
|
|
@@ -935,12 +938,12 @@ async def main() -> None:
|
|
|
935
938
|
importer = UserImporter(
|
|
936
939
|
folio_client,
|
|
937
940
|
library_name,
|
|
938
|
-
user_file_path,
|
|
939
941
|
batch_size,
|
|
940
942
|
limit_async_requests,
|
|
941
943
|
logfile,
|
|
942
944
|
errorfile,
|
|
943
945
|
http_client,
|
|
946
|
+
user_file_path,
|
|
944
947
|
args.user_match_key,
|
|
945
948
|
args.update_only_present_fields,
|
|
946
949
|
args.default_preferred_contact_type,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|