Package biblio :: Package webquery :: Module loc
[hide private]
[frames] | no frames]

Source Code for Module biblio.webquery.loc

 1  #! /usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  """ 
 4  Querying the Library of Congress for bibliographic information. 
 5  """ 
 6  # TODO: error-handling logic is correct? 
 7   
 8  __docformat__ = 'restructuredtext en' 
 9   
10   
11  ### IMPORTS ### 
12   
13  from basewebquery import BaseWebquery 
14  import querythrottle 
15   
16   
17  ### CONSTANTS & DEFINES ### 
18   
19  LOC_ROOTURL = \ 
20     'http://z3950.loc.gov:7090/voyager?operation=searchRetrieve&version=1.1' 
21   
22   
23  ### IMPLEMENTATION ### 
24   
25 -class LocQuery (BaseWebquery):
26
27 - def __init__ (self, timeout=5.0, limits=None):
28 """ 29 C'tor. 30 """ 31 root_url = LOC_ROOTURL % {'key': key} 32 BaseWebquery.__init__ (self, root_url=root_url,timeout=timeout, 33 limits=limits)
34
35 - def query_bibdata_by_isbn (self, isbn, format='MODS'):
36 """ 37 Return the metadata for a publication specified by ISBN. 38 """ 39 format = lower (format) 40 assert (format in ['mods', 'opacxml', 'dc', 'marcxml']) 41 sub_url = '&recordSchema=%(format)s&startRecord=1&maximumRecords=5&' \ 42 'query=bath.standardIdentifier=%(isbn)s' % { 43 'isbn': isbn, 44 'format': format, 45 } 46 return self.query (sub_url)
47 48 49 50 51 ### TEST & DEBUG ### 52
53 -def _doctest ():
54 import doctest 55 doctest.testmod()
56 57 58 ### MAIN ### 59 60 if __name__ == '__main__': 61 _doctest() 62 63 64 ### END ###################################################################### 65