folio-data-import 0.2.0__tar.gz → 0.2.2__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.

@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: folio_data_import
3
- Version: 0.2.0
3
+ Version: 0.2.2
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
@@ -13,6 +13,11 @@ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Dist: aiofiles (>=24.1.0,<25.0.0)
16
+ Requires-Dist: flake8-bandit (>=4.1.1,<5.0.0)
17
+ Requires-Dist: flake8-black (>=0.3.6,<0.4.0)
18
+ Requires-Dist: flake8-bugbear (>=24.8.19,<25.0.0)
19
+ Requires-Dist: flake8-docstrings (>=1.7.0,<2.0.0)
20
+ Requires-Dist: flake8-isort (>=6.1.1,<7.0.0)
16
21
  Requires-Dist: folioclient (>=0.60.5,<0.61.0)
17
22
  Requires-Dist: httpx (>=0.23.0,<0.24.0)
18
23
  Requires-Dist: inquirer (>=3.4.0,<4.0.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "folio_data_import"
3
- version = "0.2.0"
3
+ version = "0.2.2"
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"
@@ -22,10 +22,17 @@ inquirer = "^3.4.0"
22
22
  tqdm = "^4.66.5"
23
23
  tabulate = "^0.9.0"
24
24
  aiofiles = "^24.1.0"
25
+ flake8-black = "^0.3.6"
26
+ flake8-bugbear = "^24.8.19"
27
+ flake8-bandit = "^4.1.1"
28
+ flake8-isort = "^6.1.1"
29
+ flake8-docstrings = "^1.7.0"
25
30
 
26
31
 
27
32
  [tool.poetry.group.dev.dependencies]
28
33
  pytest = "^8.3.2"
34
+ flake8 = "^7.1.1"
35
+ black = "^24.8.0"
29
36
 
30
37
  [build-system]
31
38
  requires = ["poetry-core"]
@@ -436,6 +436,12 @@ async def main() -> None:
436
436
  parser = argparse.ArgumentParser()
437
437
  parser.add_argument("--gateway_url", type=str, help="The FOLIO API Gateway URL")
438
438
  parser.add_argument("--tenant_id", type=str, help="The FOLIO tenant ID")
439
+ parser.add_argument(
440
+ "--member_tenant_id",
441
+ type=str,
442
+ help="The FOLIO ECS member tenant ID (if applicable)",
443
+ default="",
444
+ )
439
445
  parser.add_argument("--username", type=str, help="The FOLIO username")
440
446
  parser.add_argument("--password", type=str, help="The FOLIO password", default="")
441
447
  parser.add_argument(
@@ -480,6 +486,11 @@ async def main() -> None:
480
486
  folio_client = folioclient.FolioClient(
481
487
  args.gateway_url, args.tenant_id, args.username, args.password
482
488
  )
489
+
490
+ # Set the member tenant id if provided to support FOLIO ECS multi-tenant environments
491
+ if args.member_tenant_id:
492
+ folio_client.okapi_headers["x-okapi-tenant"] = args.member_tenant_id
493
+
483
494
  if not args.import_profile_name:
484
495
  import_profiles = folio_client.folio_get(
485
496
  "/data-import-profiles/jobProfiles",
@@ -238,19 +238,20 @@ class UserImporter: # noqa: R0902
238
238
  None
239
239
  """
240
240
  mapped_departments = []
241
- for department in user_obj["departments"]:
241
+ for department in user_obj.pop("departments", []):
242
242
  try:
243
243
  mapped_departments.append(self.department_map[department])
244
244
  except KeyError:
245
245
  print(
246
- f'Row {line_number}: Department "{department}" not found, '
246
+ f'Row {line_number}: Department "{department}" not found, ' # noqa: B907
247
247
  f"excluding department from user"
248
248
  )
249
249
  await self.logfile.write(
250
- f'Row {line_number}: Department "{department}" not found, '
250
+ f'Row {line_number}: Department "{department}" not found, ' # noqa: B907
251
251
  f"excluding department from user\n"
252
252
  )
253
- user_obj["departments"] = mapped_departments
253
+ if mapped_departments:
254
+ user_obj["departments"] = mapped_departments
254
255
 
255
256
  async def update_existing_user(self, user_obj, existing_user) -> Tuple[dict, dict]:
256
257
  """
@@ -630,6 +631,11 @@ async def main() -> None:
630
631
  """
631
632
  parser = argparse.ArgumentParser()
632
633
  parser.add_argument("--tenant_id", help="The tenant id")
634
+ parser.add_argument(
635
+ "--member_tenant_id",
636
+ help="The FOLIO ECS member tenant id (if applicable)",
637
+ default="",
638
+ )
633
639
  parser.add_argument("--library_name", help="The name of the library")
634
640
  parser.add_argument("--username", help="The FOLIO username")
635
641
  parser.add_argument("--okapi_url", help="The Okapi URL")
@@ -672,8 +678,15 @@ async def main() -> None:
672
678
  args.username,
673
679
  args.folio_password
674
680
  or os.environ.get("FOLIO_PASS", "")
675
- or getpass.getpass("Enter your FOLIO password: "),
681
+ or getpass.getpass(
682
+ "Enter your FOLIO password: ",
683
+ ),
676
684
  )
685
+
686
+ # Set the member tenant id if provided to support FOLIO ECS multi-tenant environments
687
+ if args.member_tenant_id:
688
+ folio_client.okapi_headers["x-okapi-tenant"] = args.member_tenant_id
689
+
677
690
  user_file_path = Path(args.user_file_path)
678
691
  log_file_path = (
679
692
  user_file_path.parent.parent
@@ -45,7 +45,10 @@ async def main():
45
45
  parser.add_argument(
46
46
  "--consolidate",
47
47
  action="store_true",
48
- help="Consolidate records into a single job. Default is to create a new job for each MARC file.",
48
+ help=(
49
+ "Consolidate records into a single job. "
50
+ "Default is to create a new job for each MARC file."
51
+ ),
49
52
  )
50
53
  parser.add_argument(
51
54
  "--no-progress",
@@ -96,7 +99,10 @@ async def main():
96
99
  print("Error importing files: " + str(e))
97
100
  raise
98
101
  elif args.record_type.lower() == "users":
99
- print("User import not yet implemented. Run UserImport.py directly or use folio-user-import CLI.")
102
+ print(
103
+ "User import not yet implemented. Run UserImport.py directly "
104
+ "or use folio-user-import CLI."
105
+ )
100
106
  else:
101
107
  print("Record type not supported. Supported types are: MARC21")
102
108