Hello all,
I hadn't realized the name of the "status" property in the Leader object had changed to "record_status", and so I was generating bad records b/c my code was still using "leader.status" and the Leader was effectively dropping that setting from the generated records. I went on to use MarcEdit to make a mass change in the record set to add the "new" flag where it needs to be (leader[5]):
I've added a merge request to change that text in the Leader (
https://gitlab.com/pymarc/pymarc/-/merge_requests/204), but it's illustrative of the larger issue that the Leader allows any property name to be set, regardless of whether that property exists in the Leader or not. If the property doesn't exist, the Leader will accept the property setting without actually setting anything in the leader and without throwing an error.
I've tried and failed to fix that issue in the code with stuff like this, but so far I don't have a working fix:
def __setitem__(self, item: str, value: str) -> None:
"""Set values using position, slice or properties.
leader[5] = "a"
leader[0:4] = "0000"
leader.record_status = "a"
"""
if not isinstance(item, (slice, int)):
raise BadLeaderValue(
"Leader object can only be indexed by slice or integer"
)
# ... handle slice and index assignment ...
elif isinstance(item, slice):
self._replace_values(position=item.start, value=value)
elif isinstance(item, int):
self._replace_values(position=item, value=value)
else: # Assumes a property name is given
self.set_leader_property(self, item, value)
def set_leader_property(self, item: str, value: str):
if not hasattr(self, item):
raise AttributeError(
f"The Leader object does not have a property named '{item}'"
)
setattr(self, item, value)