[open-ils-commits] r213 - servres/trunk/conifer/libsystems/z3950 (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Mar 23 22:38:49 EDT 2009
Author: gfawcett
Date: 2009-03-23 22:38:47 -0400 (Mon, 23 Mar 2009)
New Revision: 213
Modified:
servres/trunk/conifer/libsystems/z3950/yaz_search.py
Log:
more robust yaz_search.
Modified: servres/trunk/conifer/libsystems/z3950/yaz_search.py
===================================================================
--- servres/trunk/conifer/libsystems/z3950/yaz_search.py 2009-03-24 02:25:29 UTC (rev 212)
+++ servres/trunk/conifer/libsystems/z3950/yaz_search.py 2009-03-24 02:38:47 UTC (rev 213)
@@ -13,7 +13,7 @@
loc_to_unicode = marctools.locToUTF8().replace
-LOG = None # for pexpect debugging, try LOG = sys.stderr
+LOG = sys.stderr #None # for pexpect debugging, try LOG = sys.stderr
YAZ_CLIENT = 'yaz-client'
GENERAL_TIMEOUT = 10
PRESENT_TIMEOUT = 30
@@ -50,12 +50,10 @@
return []
raw_records = []
- for x in range(to_show):
- server.expect(r'Record type: XML', timeout=PRESENT_TIMEOUT)
- server.expect('<record .*</record>')
- raw_records.append(server.match.group(0))
-
+ err = None
server.expect('nextResultSetPosition')
+ pat = re.compile('<record .*?</record>', re.M)
+ raw_records = pat.findall(server.before)
server.expect('Z>')
server.sendline('quit')
server.close()
@@ -64,7 +62,10 @@
for rec in raw_records:
dct = {}
parsed.append(dct)
- tree = ElementTree.fromstring(rec)
+ try:
+ tree = ElementTree.fromstring(rec)
+ except:
+ raise rec
for df in tree.findall('{http://www.loc.gov/MARC21/slim}datafield'):
t = df.attrib['tag']
for sf in df.findall('{http://www.loc.gov/MARC21/slim}subfield'):
More information about the open-ils-commits
mailing list