#NEWLINE# def _lookup_doi_from_biblio( self , biblio , cache_enabled ) : #NEWLINE# #INDENT# if ( not biblio ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( biblio [ 'journal' ] == '' ) : #NEWLINE# #INDENT# logger . info ( ( '%20s /biblio_print NO DOI because no journal in %s' % ( self . provider_name , biblio ) ) ) #NEWLINE# return [ ] #NEWLINE# #UNINDENT# query_string = ( '|%s|%s|%s|%s|%s|%s||%s|' % ( biblio . get ( 'journal' , '' ) , biblio . get ( 'first_author' , biblio . get ( 'authors' , '' ) . split ( ',' ) [ 0 ] . strip ( ) ) , biblio . get ( 'volume' , '' ) , biblio . get ( 'number' , '' ) , biblio . get ( 'first_page' , '' ) , biblio . get ( 'year' , '' ) , 'ImpactStory' ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# logger . info ( ( '%20s /biblio_print NO DOI because missing needed attribute in %s' % ( self . provider_name , biblio ) ) ) #NEWLINE# return [ ] #NEWLINE# #UNINDENT# url = ( 'http://doi.crossref.org/servlet/query?pid=totalimpactdev@gmail.com&qdata=%s' % query_string ) #NEWLINE# try : #NEWLINE# #INDENT# logger . debug ( ( '%20s /biblio_print calling crossref at %s' % ( self . provider_name , url ) ) ) #NEWLINE# response = self . http_get ( url , timeout = 30 , cache_enabled = cache_enabled ) #NEWLINE# #UNINDENT# except ProviderTimeout : #NEWLINE# #INDENT# raise ProviderTimeout ( 'CrossRef timeout' ) #NEWLINE# #UNINDENT# if ( response . status_code != 200 ) : #NEWLINE# #INDENT# raise ProviderServerError ( 'CrossRef status code was not 200' ) #NEWLINE# #UNINDENT# if ( not ( biblio [ 'journal' ] . lower ( ) in response . text . lower ( ) ) ) : #NEWLINE# #INDENT# raise ProviderServerError ( 'CrossRef returned invalid text response' ) #NEWLINE# #UNINDENT# response_lines = response . text . split ( '\n' ) #NEWLINE# split_lines = [ line . split ( '|' ) for line in response_lines if line ] #NEWLINE# line_keys = [ line [ ( - 2 ) ] . strip ( ) for line in split_lines ] #NEWLINE# dois = [ line [ ( - 1 ) ] . strip ( ) for line in split_lines ] #NEWLINE# for ( key , doi ) in zip ( line_keys , dois ) : #NEWLINE# #INDENT# if ( not doi ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# logger . debug ( ( '%20s /biblio_print NO DOI from %s, %s' % ( self . provider_name , biblio , key ) ) ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# logger . debug ( ( '%20s /biblio_print NO DOI from %s, %s' % ( self . provider_name , '' , key ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return doi