-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.
-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
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':
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']
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:
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.':
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