EUTILS_WSDL_URL = 'http://eutils.ncbi.nlm.nih.gov/soap/v2.0/eutils.wsdl'
EFETCH_WSDL_URL = 'http://eutils.ncbi.nlm.nih.gov/soap/v2.0/efetch_%s.wsdl'
EFETCH_PLAIN_URL = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi'
+NCBI_PLAIN_URL = 'http://www.ncbi.nlm.nih.gov/%s/%s'
EUTILS_CLIENT = _Client(EUTILS_WSDL_URL)
xml = f.read()
f.close()
# Remove wrapping HTML and unescape XML
+ #LOG.debug('raw data:\n%s' % xml)
xml = xml.split('<pre>', 1)[-1]
xml = xml.split('</pre>', 1)[0]
xml = _unescape(xml, {'"': '"'})
+ #LOG.debug('xml data:\n%s' % xml)
+ if not xml.strip(): #
+ urls = [NCBI_PLAIN_URL % (options.database, id)
+ for id in q.IdList.Id]
+ LOG.warn(
+ 'no meaningful output; try:\n%s' % '\n'.join(urls))
else: # Use SOAP eFetch
LOG.info('run eFetch on %s' % options.database)
f = efetch_client.service.run_eFetch(
raise Exception(f.ERROR)
xml = efetch_client.last_received()
- if output == 'medline':
+ if output is None:
+ pass # we're bailing
+ elif output == 'medline':
outfile.write(str(xml).rstrip()+'\n')
elif output == 'bibtex':
outfile.write(medline_xml_to_bibtex(str(xml)))