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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: folio_data_import
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "folio_data_import"
3
- version = "0.2.2"
3
+ version = "0.2.4"
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"
@@ -181,12 +181,15 @@ class UserImporter: # noqa: R0902
181
181
  KeyError: If an address type name in the user object is not found in address_type_map.
182
182
 
183
183
  """
184
- if "personal" in user_obj and "addresses" in user_obj["personal"]:
185
- for address in user_obj["personal"]["addresses"]:
184
+ if "personal" in user_obj:
185
+ addresses = user_obj["personal"].pop("addresses", [])
186
+ mapped_addresses = []
187
+ for address in addresses:
186
188
  try:
187
189
  address["addressTypeId"] = self.address_type_map[
188
190
  address["addressTypeId"]
189
191
  ]
192
+ mapped_addresses.append(address)
190
193
  except KeyError:
191
194
  if address["addressTypeId"] not in self.address_type_map.values():
192
195
  print(
@@ -197,9 +200,8 @@ class UserImporter: # noqa: R0902
197
200
  f"Row {line_number}: Address type {address['addressTypeId']} not found"
198
201
  f", removing address\n"
199
202
  )
200
- del address
201
- if len(user_obj["personal"]["addresses"]) == 0:
202
- del user_obj["personal"]["addresses"]
203
+ if mapped_addresses:
204
+ user_obj["personal"]["addresses"] = mapped_addresses
203
205
 
204
206
  async def map_patron_groups(self, user_obj, line_number) -> None:
205
207
  """
@@ -594,7 +596,9 @@ class UserImporter: # noqa: R0902
594
596
  await self.logfile.write(message + "\n")
595
597
  tasks = []
596
598
  if tasks:
599
+ start = time.time()
597
600
  await asyncio.gather(*tasks)
601
+ duration = time.time() - start
598
602
  async with self.lock:
599
603
  message = (
600
604
  f"{dt.now().isoformat(sep=' ', timespec='milliseconds')}: "