From 54a3e560183e17b9811b8e317c99add72e37d8bc Mon Sep 17 00:00:00 2001 From: gfawcett Date: Wed, 29 Dec 2010 15:54:12 +0000 Subject: [PATCH] tweaks to RIS import git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1148 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/views/items.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index c87b18f..fad6e46 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -113,26 +113,25 @@ def item_add(request, site_id, item_id): ris = defaultdict(list) for k, v in tmp: ris[k].append(v) - def update(field, risfield, xlate=lambda x: x): - if risfield in ris: - replacement = '; '.join(ris[risfield]) - POST[field] = xlate(replacement) + def update(field, risfields, xlate=lambda x: x): + for risfield in risfields: + if risfield in ris: + replacement = '; '.join(ris[risfield]) + POST[field] = xlate(replacement) + break def space_comments(names): # RIS doesn't put spaces after commas in names return re.sub(',(?=[^ ])', ', ', names) - update('title', 'TI') # first try TI, then T1 - update('title', 'T1') - update('source_title', 'JO') # first try JO, then JF - update('source_title', 'JF') - update('author', 'AU', space_comments) # first try AU, then A1 - update('author', 'A1', space_comments) - update('url', 'UR') - update('volume', 'VL') - update('issue', 'IS') + update('title', ('TI', 'T1')) + update('source_title', ('JO', 'JF')) + update('author', ('AU', 'A1'), space_comments) + update('url', ('UR',)) + update('volume', ('VL',)) + update('issue', ('IS',)) + update('published', ('PY', 'Y1'), lambda v: v.split('/')[0]) if 'SP' in ris and 'EP' in ris: POST['pages'] = ris['SP'][0] + '-' + ris['EP'][0] - update('published', 'PY', lambda v: v.split('/')[0]) if item_type == 'HEADING': -- 2.11.0