@@ -128,26 +128,6 @@ def test_status(points):
128128 return test_status
129129
130130
131- def oai_identify (oai_base ):
132- action = "?verb=Identify"
133- return oai_request (oai_base , action )
134-
135-
136- def oai_metadataFormats (oai_base ):
137- action = "?verb=ListMetadataFormats"
138- xmlTree = oai_request (oai_base , action )
139- metadataFormats = {}
140- for e in xmlTree .findall (".//{http://www.openarchives.org/OAI/2.0/}metadataFormat" ):
141- metadataPrefix = e .find (
142- "{http://www.openarchives.org/OAI/2.0/}metadataPrefix"
143- ).text
144- namespace = e .find (
145- "{http://www.openarchives.org/OAI/2.0/}metadataNamespace"
146- ).text
147- metadataFormats [metadataPrefix ] = namespace
148- return metadataFormats
149-
150-
151131def is_persistent_id (item_id ):
152132 """Returns boolean if the item id is or not a persistent identifier.
153133
@@ -448,119 +428,6 @@ def check_metadata_terms_with_values(metadata, terms):
448428 return df_access
449429
450430
451- def oai_check_record_url (oai_base , metadata_prefix , pid ):
452- endpoint_root = urllib .parse .urlparse (oai_base ).netloc
453- try :
454- pid_type = idutils .detect_identifier_schemes (pid )[0 ]
455- except Exception as e :
456- pid_type = "internal"
457- logging .error (e )
458- if pid_type != "internal" :
459- oai_pid = idutils .normalize_pid (pid , pid_type )
460- else :
461- oai_pid = pid
462- action = "?verb=GetRecord"
463-
464- test_id = "oai:%s:%s" % (endpoint_root , oai_pid )
465- params = "&metadataPrefix=%s&identifier=%s" % (metadata_prefix , test_id )
466- url_final = ""
467- url = oai_base + action + params
468- response = requests .get (url , verify = False , allow_redirects = True )
469- logging .debug ("Trying ID v1: url: %s | status: %i" % (url , response .status_code ))
470- error = 0
471- for tags in ET .fromstring (response .text ).findall (
472- ".//{http://www.openarchives.org/OAI/2.0/}error"
473- ):
474- error = error + 1
475- if error == 0 :
476- url_final = url
477-
478- test_id = "%s" % (oai_pid )
479- params = "&metadataPrefix=%s&identifier=%s" % (metadata_prefix , test_id )
480-
481- url = oai_base + action + params
482- logging .debug ("Trying: " + url )
483- response = requests .get (url , verify = False )
484- error = 0
485- for tags in ET .fromstring (response .text ).findall (
486- ".//{http://www.openarchives.org/OAI/2.0/}error"
487- ):
488- error = error + 1
489- if error == 0 :
490- url_final = url
491-
492- test_id = "%s:%s" % (pid_type , oai_pid )
493- params = "&metadataPrefix=%s&identifier=%s" % (metadata_prefix , test_id )
494-
495- url = oai_base + action + params
496- logging .debug ("Trying: " + url )
497- response = requests .get (url , verify = False )
498- error = 0
499- for tags in ET .fromstring (response .text ).findall (
500- ".//{http://www.openarchives.org/OAI/2.0/}error"
501- ):
502- error = error + 1
503- if error == 0 :
504- url_final = url
505-
506- test_id = "oai:%s:%s" % (
507- endpoint_root ,
508- oai_pid [oai_pid .rfind ("." ) + 1 : len (oai_pid )],
509- )
510- params = "&metadataPrefix=%s&identifier=%s" % (metadata_prefix , test_id )
511-
512- url = oai_base + action + params
513- logging .debug ("Trying: " + url )
514- response = requests .get (url , verify = False )
515- error = 0
516- for tags in ET .fromstring (response .text ).findall (
517- ".//{http://www.openarchives.org/OAI/2.0/}error"
518- ):
519- error = error + 1
520- if error == 0 :
521- url_final = url
522-
523- test_id = "oai:%s:b2rec/%s" % (
524- endpoint_root ,
525- oai_pid [oai_pid .rfind ("." ) + 1 : len (oai_pid )],
526- )
527- params = "&metadataPrefix=%s&identifier=%s" % (metadata_prefix , test_id )
528-
529- url = oai_base + action + params
530- logging .debug ("Trying: " + url )
531- response = requests .get (url , verify = False )
532- error = 0
533- for tags in ET .fromstring (response .text ).findall (
534- ".//{http://www.openarchives.org/OAI/2.0/}error"
535- ):
536- error = error + 1
537- if error == 0 :
538- url_final = url
539-
540- return url_final
541-
542-
543- def oai_get_metadata (url ):
544- logging .debug ("Metadata from: %s" % url )
545- oai = requests .get (url , verify = False , allow_redirects = True )
546- try :
547- xmlTree = ET .fromstring (oai .text )
548- except Exception as e :
549- logging .error ("OAI_RQUEST: %s" % e )
550- xmlTree = None
551- return xmlTree
552-
553-
554- def oai_request (oai_base , action ):
555- oai = requests .get (oai_base + action , verify = False ) # Peticion al servidor
556- try :
557- xmlTree = ET .fromstring (oai .text )
558- except Exception as e :
559- logging .error ("OAI_RQUEST: %s" % e )
560- xmlTree = ET .fromstring ("<OAI-PMH></OAI-PMH>" )
561- return xmlTree
562-
563-
564431def find_dataset_file (metadata , url , data_formats ):
565432 headers = {
566433 "User-Agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"
0 commit comments