From 69fc2cf3b835c67e23ac29dfd99b4bde8df3d909 Mon Sep 17 00:00:00 2001 From: Art Rhyno Date: Tue, 7 Feb 2012 00:22:35 -0500 Subject: [PATCH] Make xmlmarc import more fault tolerant --- conifer/libsystems/marcxml.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/conifer/libsystems/marcxml.py b/conifer/libsystems/marcxml.py index 23c2f92..0f828a1 100644 --- a/conifer/libsystems/marcxml.py +++ b/conifer/libsystems/marcxml.py @@ -35,7 +35,10 @@ def record_to_dictionary(rec, multiples=True): c = sf.attrib['code'] v = sf.text or '' dct.setdefault(t+c, []).append(v) - dct = dict((k,'\n'.join(v or [])) for k,v in dct.items()) + try: + dct = dict((k,'\n'.join(v or [])) for k,v in dct.items()) + except TypeError: + print "Unable to extract all of the record" return dct def marcxml_to_dictionary(rec, multiples=False): @@ -59,7 +62,11 @@ def marcxml_to_dictionary(rec, multiples=False): c = sf.attrib['code'] v = sf.text or '' dct.setdefault(t+c, []).append(v) - dct = dict((k,'\n'.join(v or [])) for k,v in dct.items()) + try: + dct = dict((k,'\n'.join(v or [])) for k,v in dct.items()) + except TypeError: + print "Unable to extract all of the record" + out.append(dct) if multiples is False: return out and out[0] or None -- 2.11.0