[open-ils-commits] r1086 - conifer/branches/rel_1_6_1/tools/ebooks (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 24 23:22:48 EST 2010
Author: dbs
Date: 2010-11-24 23:22:46 -0500 (Wed, 24 Nov 2010)
New Revision: 1086
Modified:
conifer/branches/rel_1_6_1/tools/ebooks/prep_ebook_records.py
Log:
And now we handle ebrary records per our spec (no proxy, substitute channel)
Modified: conifer/branches/rel_1_6_1/tools/ebooks/prep_ebook_records.py
===================================================================
--- conifer/branches/rel_1_6_1/tools/ebooks/prep_ebook_records.py 2010-11-24 22:44:12 UTC (rev 1085)
+++ conifer/branches/rel_1_6_1/tools/ebooks/prep_ebook_records.py 2010-11-25 04:22:46 UTC (rev 1086)
@@ -13,7 +13,7 @@
be accommodated in batch load.
"""
-import os, os.path, sys, getopt, pymarc, pymarc.marc8
+import os, os.path, sys, getopt, pymarc, pymarc.marc8, re
class Institution():
"""Defines standard settings for each Conifer institution"""
@@ -262,21 +262,47 @@
print "* No subfield 'u' found in this 856"
return None
+
for lib in options['libraries']:
data = options['settings'].get_settings(lib)
+ subs = get_subfields(field, data)
eight_five_six = pymarc.Field(tag = '856',
indicators = ['4', '0'],
- subfields = [
- 'u', data['proxy'] + field['u'],
- 'y', data['link_text'],
- 'z', data['public_note'],
- '9', data['code']
- ]
+ subfields = subs
)
new_fields.append(eight_five_six)
return new_fields
+def get_subfields(field, data):
+ """Creates 856 subfields required by Conifer"""
+
+ subs = []
+ url = field['u']
+
+ # Is this an ebrary URL?
+ ebrary = False
+ if url.find('.ebrary.com') > -1:
+ ebrary = True
+
+ # ebrary URLs look like: http://site.ebrary.com/lib/<channel>/Doc?id=2001019
+ # we need to replace <channel> with the library-specific channel
+ if ebrary:
+ ebrary_url = re.search(r'^(.+?/lib/).+?(/.+?)$', url)
+ url = ebrary_url.group(1) + data['ebrary_code'] + ebrary_url.group(2)
+ subs.extend(['u', url])
+ else:
+ subs.extend(['u', data['proxy'] + field['u']])
+
+ subs.extend([
+ 'y', data['link_text'],
+ 'z', data['public_note'],
+ '9', data['code']
+ ])
+
+ return subs
+
+
if __name__ == '__main__':
process_records(parse_opts())
More information about the open-ils-commits
mailing list