From: Dan Scott Date: Sat, 12 Nov 2011 05:18:51 +0000 (-0500) Subject: Don't srip our own 924 field from the record X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8f9276cafd318f3e79bedb39efeb53f42d563bfe;p=contrib%2FConifer.git Don't srip our own 924 field from the record Also, a lot of other changes to make the ebrary option actually work. Signed-off-by: Dan Scott --- diff --git a/tools/ebooks/prep_ebook_records.py b/tools/ebooks/prep_ebook_records.py index 99f54f10bb..eae159896f 100644 --- a/tools/ebooks/prep_ebook_records.py +++ b/tools/ebooks/prep_ebook_records.py @@ -96,8 +96,6 @@ Required arguments: -o / --output : The name of the output MARC file. - -e / --ebrary-id : Put Ebrary 001 into 924 as a URN for SFX lookup purposes - -a / --authorization: The name of the online platorm to be inserted in each 506$e access restriction note. @@ -117,6 +115,8 @@ Required arguments: -W / --windsor : Add an 856 for University of Windsor Optional arguments: + -e / --ebrary : Put Ebrary 001 into 924 as a URN for SFX lookup purposes + -n / --note : The text of the internal note to be inserted into a 590 field. -s / --sample : The name of the sample output MARC file (generates @@ -144,7 +144,7 @@ def consolidate_options(opts): elif key == '-c': _options['--consortium'] = val elif key == '-e': - _options['--ebrary-id'] = val + _options['--ebrary'] = val elif key == '-p': _options['--publisher'] = val elif key == '-P': @@ -221,6 +221,9 @@ def check_options(options): clean_opts['consortium'] = options['--consortium'] clean_opts['authorization'] = options['--authorization'] + if '--ebrary' in options: + clean_opts['ebrary'] = True + if '--sample' in options: clean_opts['sample'] = options['--sample'] @@ -266,10 +269,10 @@ def check_libraries(options): def parse_opts(): """Get command-line arguments from the script""" try: - _short_opts = 'i:o:a:c:p:ALWne:P:s:h' + _short_opts = 'i:o:a:c:p:ALWen:P:s:h' _long_opts = ['input=', 'output=', 'authorization=', 'consortium=', - 'publisher=', 'algoma', 'laurentian', 'windsor', 'note=', - 'platform=', 'sample=', 'ebrary-id', 'help' + 'publisher=', 'algoma', 'laurentian', 'windsor', 'ebrary', + 'note=', 'platform=', 'sample=', 'help' ] opts = getopt.getopt(sys.argv[1:], _short_opts, _long_opts) except getopt.GetoptError, ex: @@ -340,7 +343,8 @@ def process_fields(record, options): for new_856 in new_fields: new_record.add_field(new_856) # Strip out 9xx fields: we don't want local fields in our records - elif field.tag[0] == '9': + # except for 924 fields that we create + elif field.tag[0] == '9' and field.tag != '924': pass # Strip out 300 fields that only contain placeholders elif field.tag == '300' and field['a'] == 'p. cm.': @@ -602,17 +606,20 @@ def mark_isbn_for_sfx(record, options): return True # For ebrary records, add a 924 for the custom URN - if options['ebrary-id'] is True: - for scn in record.get_field('001'): + if options['ebrary'] is True: + urn = None + for scn in record.get_fields('001'): urn = pymarc.Field(tag = '924', indicators = ['8', ' '], subfields = [ - 'a', 'urn:ebrary:' + scn.value(), + 'a', scn.value(), '9', 'SFX' ] ) + if urn is not None: record.add_field(urn) + return True return False