folio-data-import 0.2.8rc1__tar.gz → 0.2.8rc3__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
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: folio_data_import
3
- Version: 0.2.8rc1
3
+ Version: 0.2.8rc3
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.8rc1"
3
+ version = "0.2.8rc3"
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"
@@ -539,7 +539,7 @@ class UserImporter: # noqa: R0902
539
539
  and the existing PU object (existing_pu).
540
540
  """
541
541
  rp_obj = user_obj.pop("requestPreference", {})
542
- spu_obj = user_obj.pop("servicePointsUser")
542
+ spu_obj = user_obj.pop("servicePointsUser", {})
543
543
  existing_user = await self.get_existing_user(user_obj)
544
544
  if existing_user:
545
545
  existing_rp = await self.get_existing_rp(user_obj, existing_user)
@@ -769,7 +769,7 @@ class UserImporter: # noqa: R0902
769
769
  existing_spu (dict): The existing service-points-user object, if it exists.
770
770
  existing_user (dict): The existing user object associated with the spu_obj.
771
771
  """
772
- if spu_obj is not None:
772
+ if spu_obj:
773
773
  await self.map_service_points(spu_obj, existing_user)
774
774
  if existing_spu:
775
775
  await self.update_existing_spu(spu_obj, existing_spu)
@@ -0,0 +1,84 @@
1
+ import pymarc
2
+
3
+ def prepend_prefix_001(record: pymarc.Record, prefix: str) -> pymarc.Record:
4
+ """
5
+ Prepend a prefix to the record's 001 field.
6
+
7
+ Args:
8
+ record (pymarc.Record): The MARC record to preprocess.
9
+ prefix (str): The prefix to prepend to the 001 field.
10
+
11
+ Returns:
12
+ pymarc.Record: The preprocessed MARC record.
13
+ """
14
+ record['001'].data = f'({prefix})' + record['001'].data
15
+ return record
16
+
17
+ def prepend_ppn_prefix_001(record: pymarc.Record) -> pymarc.Record:
18
+ """
19
+ Prepend the PPN prefix to the record's 001 field. Useful when
20
+ importing records from the ABES SUDOC catalog
21
+
22
+ Args:
23
+ record (pymarc.Record): The MARC record to preprocess.
24
+
25
+ Returns:
26
+ pymarc.Record: The preprocessed MARC record.
27
+ """
28
+ return prepend_prefix_001(record, 'PPN')
29
+
30
+ def prepend_abes_prefix_001(record: pymarc.Record) -> pymarc.Record:
31
+ """
32
+ Prepend the ABES prefix to the record's 001 field. Useful when
33
+ importing records from the ABES SUDOC catalog
34
+
35
+ Args:
36
+ record (pymarc.Record): The MARC record to preprocess.
37
+
38
+ Returns:
39
+ pymarc.Record: The preprocessed MARC record.
40
+ """
41
+ return prepend_prefix_001(record, 'ABES')
42
+
43
+ def strip_999_ff_fields(record: pymarc.Record) -> pymarc.Record:
44
+ """
45
+ Strip all 999 fields with ff indicators from the record.
46
+ Useful when importing records exported from another FOLIO system
47
+
48
+ Args:
49
+ record (pymarc.Record): The MARC record to preprocess.
50
+
51
+ Returns:
52
+ pymarc.Record: The preprocessed MARC record.
53
+ """
54
+ for field in record.get_fields('999'):
55
+ if field.indicators == pymarc.Indicators(*['f', 'f']):
56
+ record.remove_field(field)
57
+ return record
58
+
59
+ def sudoc_supercede_prep(record: pymarc.Record) -> pymarc.Record:
60
+ """
61
+ Preprocesses a record from the ABES SUDOC catalog to copy 035 fields
62
+ with a $9 subfield value of 'sudoc' to 935 fields with a $a subfield
63
+ prefixed with "(ABES)". This is useful when importing newly-merged records
64
+ from the SUDOC catalog when you want the new record to replace the old one
65
+ in FOLIO. This also applyes the prepend_ppn_prefix_001 function to the record.
66
+
67
+ Args:
68
+ record (pymarc.Record): The MARC record to preprocess.
69
+
70
+ Returns:
71
+ pymarc.Record: The preprocessed MARC record.
72
+ """
73
+ record = prepend_abes_prefix_001(record)
74
+ for field in record.get_fields('035'):
75
+ if "a" in field and "9" in field and field['9'] == 'sudoc':
76
+ _935 = pymarc.Field(
77
+ tag='935',
78
+ indicators=['f', 'f'],
79
+ subfields=[
80
+ pymarc.field.Subfield('a', "(ABES)" + field['a'])
81
+ ]
82
+ )
83
+ record.add_ordered_field(_935)
84
+ return record
@@ -1,31 +0,0 @@
1
- import pymarc
2
-
3
- def prepend_ppn_prefix_001(record: pymarc.Record) -> pymarc.Record:
4
- """
5
- Prepend the PPN prefix to the record's 001 field. Useful when
6
- importing records from the ABES SUDOC catalog
7
-
8
- Args:
9
- record (pymarc.Record): The MARC record to preprocess.
10
-
11
- Returns:
12
- pymarc.Record: The preprocessed MARC record.
13
- """
14
- record['001'].data = '(PPN)' + record['001'].data
15
- return record
16
-
17
- def strip_999_ff_fields(record: pymarc.Record) -> pymarc.Record:
18
- """
19
- Strip all 999 fields with ff indicators from the record.
20
- Useful when importing records exported from another FOLIO system
21
-
22
- Args:
23
- record (pymarc.Record): The MARC record to preprocess.
24
-
25
- Returns:
26
- pymarc.Record: The preprocessed MARC record.
27
- """
28
- for field in record.get_fields('999'):
29
- if field.indicators == pymarc.Indicators(*['f', 'f']):
30
- record.remove_field(field)
31
- return record