edsu / pymarc

process MARC records from Python
http://python.org/pypi/pymarc
Other
251 stars 99 forks source link

field .indicators, indicator1, indicator2 confusion #107

Closed Wooble closed 5 years ago

Wooble commented 6 years ago

a pymarc.field.Field object has both a .indicators attribute (which is a list of 2 indicators), and .indicator1 and .indicator2 attributes, which are strings that are set initially to the same values as in indicators.

Field.str uses the indicators list to determine what indicators to display in the textual format, while as_marc uses the individual attributes.

The upshot of this is that you if you want to edit indicators in the MARC you'll output, you need to change the individual attributes, but printing the record as text will make it appear you didn't change anything, while changing .indicators[1], for example, will appear to edit the indicator when printing for debugging, but when the MARC is written out it will still have the old value.

edsu commented 5 years ago

Fixed by #131

edsu commented 5 years ago

Thanks for tending to this @wooble -- it was a thorny bit of code that could have led to some undesirable behavior. I just released this as part of v3.1.12

Wooble commented 5 years ago

@edsu Yeah, fortunately I only messed up a small batch of records in production before noticing the incorrect indicators, debugging for a while, and being reminded of this issue which I'd totally forgotten reporting. Seemed like a good idea to fix it before the next time I forget and break a lot more records :)