A sweetened pymarc.Record module tailored for data extraction from local Sierra's MARC dumps.
Install via pip:
python -m pip install git+https://github.com/BookOps-CAT/bookops-marcfrom bookops_marc import SierraBibReader
with open('marc.mrc', "rb") as marcfile:
reader = SierraBibReader(marcfile)
for bib in reader:
print(bib.sierra_bib_id_normalized)
print(bib.sierra_bib_format)
print(bib.branch_call_no)
print(bib.orders)
print(bib.main_entry)
print(bib.form_of_item)
print(bib.dewey)
print(bib.dewey_shortened)In certain scenarios it may be convenient to instantiate a Bib directly from an instance of pymarc.Record. This can be accomplished using the Bib.pymarc_record_to_local_bib() classmethod:
from pymarc import Record
from bookops_marc.bib import pymarc_record_to_local_bib
# pymarc Record instance
record = Record()
bib = Bib.pymarc_record_to_local_bib(record, "bpl")
bib.remove_unsupported_subjects()Python 3.10 and up.
0.12.1
0.12.1 - 2026-04-08
- Python 3.14 to unit tests in GitHub actions
0.12.0 - 2025-1-13
- Python 3.13 to unit tests in GitHub actions
OclcNumberclass- replaces helper functions previously in from
local_values.py:oclcNo_with_prefix,oclcNo_without_prefix,is_oclc_number,has_oclc_prefix,_add_oclc_prefixand_delete_oclc_prefix
- replaces helper functions previously in from
Itemclass to create item records associated with a bib record.Bib.item_fields,Bib.itemsandBib.barcodesproperties all rely onItemclass
Bib.collectionproperty to identify records as belonging to the branch collection, research library collection, or being a mixed bib record.Bib.research_call_no_fieldandBib.research_call_noidentify call numbers in the 852 field in a nypl record
- changed most
Bibmethods to properties. This follows the pattern that pymarc uses with managedRecordattributes:- methods changed to properties:
audiencebranch_call_nobranch_call_no_fieldcataloging_datecontrol_numbercreated_datedeweydewey_shortenedform_of_itemlanguageslccnmain_entryoclc_nosordersoverdrive_numberphysical_descriptionrecord_typesierra_bib_formatsierra_bib_idsierra_bib_id_normalizedsubjects_lcsuppressedupc_number
normalize_oclc_control_numberandremove_unsupported_subjectsare still methods as they attributes of aBibobject
- methods changed to properties:
- the
pymarc_record_to_local_bibfunction is now aclassmethodfor theBibclass Orderis now a class rather than aNamedTupleOrderobjects are instantiated from aFieldobject with an optionalfollowing_fieldparameter
- helper functions in
local_values.py. the functionality has been retained in theBib,Order, andOclcNumberclass
0.11.0 - 2024-11-13
- updated pymarc to 5.2.3
- updated dev dependencies:
- pytest (8.3.3)
- black (24.8.0)
- mypy (1.13)
- refactored code to support new
Indicatorsclass introduced inpymarc5.2.0
0.10.0 - 2024-03-16
- method to retrieve all OCLC numbers present in a bib (001, 035, 991):
bib.oclc_nos() - methods to normalize OCLC number in the 001 control field in
bib.Bibclass:bib.normalize_oclc_control_number - new module
local_valueswith the followoing methods:_add_oclc_prefix_delete_oclc_prefixhas_oclc_prefix,is_oclc_number,oclcNo_with_prefix,oclcNo_without_prefix
- dropped Python 3.7 support
- update dev dependencies:
- black (24.3.0)
- mypy (1.9)
- pytest (8.1.1)
- pytest-cov (4.1.0)
- changed
pyproject.tomlsettings for black, mypy, & coverage - deleted
requirements.txtand transition topyproject.tomlfor dependencies
0.9.0 - 2024-01-05
- updated to pymarc 5.0
- updated dev dependencies:
- black (22.12.0)
- pytest (7.4.4)
- github actions upgrade to v4
- tests for Python 3.11 & 3.12
0.8.1 - 2022-08-16
- version bump propagated to all places
0.8.0 - 2022-08-15
bib.pymarc_record_to_local_bib()method to instageBibinstance frompymarc.Recordinstancesierra_bib_format()method inBibclass that returns 998$d of Sierra record
- added basic normalization to
libraryparameter passed toBibclass stub_marctest fixture renamed tostub_bib
0.7.0 - 2022-04-16
- remove_unsupported_subjects() that deletes subject tags (6xx) which are not supported by BookOps (NYPL & BPL CAT)
- dev dependency mypy 0.942
- basic type checking
- pytest bumped to 7.1.1
- pytest-cov bumped to 3.0.0
0.6.1 - 2022-04-13
- parsing of NYPL bib created date Sierra field (907$c)
- bumps pymarc to v4.2.0
0.6.0 - 2022-02-06
- CI moved from Travis to Github-Actions
- added Python 3.10 tests
0.5.0 - 2021-11-15
bib.suppressed()method toBibwhich determines if bib is suppressed from the public display
0.4.0 - 2021-09-23
bib.control_number()method toBib(retrieves data from the tag 001)
0.3.0 - 2021-09-23
bib.lccn()(retrieves LCCN from bib),bib.overdrive_number()(retrieves Overdrive Reserve ID),bib.upc_number()(retrieves UPC from bib)
0.2.0 - [2021-08-30]
- a method for retrieving branch call number as
pymarc.Field