def frbnfBib2arkAut(NumNot, frbnf, nom, prenom, date_debut): """Recherche de l'identifiant d'auteur à partir d'une recherche N° BIB + nom d'auteur : on cherche le n° BIB comme NNB, comme FRBNF ou comme ancien numéro""" listeArk = [] systemid_full = frbnf.lower().replace("f", "").replace("r", "").replace( "b", "").replace("n", "") nnb_possible = systemid_full[0:8] url = funcs.url_requete_sru('bib.recordid all "' + nnb_possible + '"') (test, page) = funcs.testURLetreeParse(url) if (test == True): for record in page.xpath("//srw:recordData", namespaces=main.ns): listeArk.extend( extractARKautfromBIB(record, nom, prenom, date_debut)) if (listeArk == []): url = funcs.url_requete_sru('bib.otherid all "' + frbnf + '" and bib.author all "' + nom + '"') (test, page) = funcs.testURLetreeParse(url) if (test == True): for record in page.xpath("//srw:recordData", namespaces=main.ns): listeArk.extend( extractARKautfromBIB(record, nom, prenom, date_debut)) if (listeArk == []): systemid1 = systemid_full[0:9] systemid2 = systemid_full[0:8] url = funcs.url_requete_sru('bib.otherid any "' + systemid1 + " " + systemid2 + '" and bib.author all "' + nom + '"') (test, page) = funcs.testURLetreeParse(url) if (test == True): for record in page.xpath("//srw:recordData", namespaces=main.ns): listeArk.extend( extractARKautfromBIB(record, nom, prenom, date_debut)) listeArk = ",".join(set(listeArk)) return listeArk
def comparerAutBnf(NumNot, ark_current, nna, nom, origineComparaison): ark = "" url = funcs.url_requete_sru('aut.persistentid all "' + ark_current + '"') (test, recordBNF) = funcs.testURLetreeParse(url) if (test == True): ark = compareAccessPoint(NumNot, ark_current, nna, nom, recordBNF) return ark
def nna2ark(nna): url = funcs.url_requete_sru('aut.recordid any ' + nna + 'and aut.status any "sparse validated"') ark = "" (test, record) = funcs.testURLetreeParse(url) if (test): if (record.find("//srw:recordIdentifier", namespaces=main.ns) is not None): ark = record.find("//srw:recordIdentifier", namespaces=main.ns).text return ark
def arkBib2arkAut(NumNot, arkBib, nom, prenom, date_debut): """Identifier un ARK de notice d'autorité à partir d'un ARK de notice BIB + contrôle sur le nom""" url = funcs.url_requete_sru('bib.persistentid all "' + arkBib + '"') (test, page) = funcs.testURLetreeParse(url) listeArk = "" if (test == True): for record in page.xpath("//srw:recordData/mxc:record", namespaces=main.ns): listeArk.extend( extractARKautfromBIB(record, nom, prenom, date_debut)) NumNotices2methode[NumNot].append( "ARK notice BIB + contrôle accesspoint") return listeArk
def arkAut2arkAut(NumNot, ark): """Actualisation d'un ARK de notice d'autorité""" url = funcs.url_requete_sru('aut.persistentid all "' + ark + '"') (test, page) = funcs.testURLetreeParse(url) nv_ark = "" if (test == True): if (page.find("//srw:recordIdentifier", namespaces=main.ns) is not None): nv_ark = page.find("//srw:recordIdentifier", namespaces=main.ns).text NumNotices2methode[NumNot].append("Actualisation ARK") return nv_ark
def isni2ark(NumNot, isni, origine="isni"): url = funcs.url_requete_sru('aut.isni all "' + isni + '" and aut.status any "sparse validated"') (test, page) = funcs.testURLetreeParse(url) nv_ark = "" if (test == True): if (page.find("//srw:recordIdentifier", namespaces=main.ns) is not None): nv_ark = page.find("//srw:recordIdentifier", namespaces=main.ns).text if (origine == "isni"): NumNotices2methode[NumNot].append("ISNI") return nv_ark
def accesspoint2arkAut(NumNot, nom_nett, prenom_nett, date_debut, date_fin): listeArk = [] url = funcs.url_requete_sru('aut.accesspoint adj "' + " ".join([nom_nett, prenom_nett, date_debut]) + '"') testdatefin = False if (date_debut == "" and date_fin != ""): url = funcs.url_requete_sru('aut.accesspoint adj "' + " ".join([nom_nett, prenom_nett]) + '" and aut.accesspoint all "' + date_fin + '"') testdatefin = True #print(url) (test, results) = funcs.testURLetreeParse(url) if (test): for record in results.xpath("//srw:records/srw:record", namespaces=main.ns): ark = record.find("srw:recordIdentifier", namespaces=main.ns).text if (testdatefin == True): if (record.find( "srw:recordData/mxc:record/mxc:datafield[@tag='103']/mxc:subfield[@code='a']", namespaces=main.ns) is not None): f103a_datefin = record.find( "srw:recordData/mxc:record/mxc:datafield[@tag='103']/mxc:subfield[@code='a']", namespaces=main.ns).text[11:15] if (date_fin == f103a_datefin): listeArk.append(ark) NumNotices2methode[NumNot].append( "Point d'accès avec date de fin") elif (date_debut != ""): listeArk.append(ark) NumNotices2methode[NumNot].append( "Point d'accès avec date de début") else: listeArk.append(ark) NumNotices2methode[NumNot].append("Point d'accès") listeArk = ",".join(listeArk) return listeArk
def bib2arkAUT(NumNot, titre, pubDate, nom, prenom, date_debut): listeArk = [] if (pubDate == ""): pubDate = "-" url = funcs.url_requete_sru("".join([ 'bib.title all "', titre, '" and bib.author all "', nom, " ", prenom, '" and bib.publicationdate all "', pubDate, '"' ])) (test, results) = funcs.testURLetreeParse(url) if (test): for record in results.xpath("//srw:recordData/mxc:record", namespaces=main.ns): listeArk.extend( extractARKautfromBIB(record, nom, prenom, date_debut)) listeArk = ",".join(set(listeArk)) return listeArk
def relancerNNA_nomAuteur(NumNot, systemid, nom): listeArk = [] if (nom != "" and nom is not None): urlSRU = funcs.url_requete_sru('aut.accesspoint all "' + nom + '" and aut.otherid all "' + systemid + '"') (test, pageSRU) = funcs.testURLetreeParse(urlSRU) if (test == True): for record in pageSRU.xpath("//srw:records/srw:record", namespaces=main.ns): ark = record.find("srw:recordIdentifier", namespaces=main.ns).text NumNotices2methode[NumNot].append("N° sys FRBNF + Nom") listeArk.append(ark) listeArk = ",".join(listeArk) return listeArk
def rechercheNNA(NumNot, nna, nom): ark = "" if (nna.isdigit() is False): #pb_frbnf_source.write("\t".join[NumNot,nnb] + "\n") ark = "Pb FRBNF" elif (10000000 < int(nna) < 25000000): url = funcs.url_requete_sru('aut.recordid any "' + nna + '"') (test, page) = funcs.testURLetreeParse(url) if (test == True): for record in page.xpath("//srw:records/srw:record", namespaces=main.ns): ark_current = record.find("srw:recordIdentifier", namespaces=main.ns).text ark = comparerAutBnf(NumNot, ark_current, nna, nom, "Numéro de notice") return ark
def frbnfAut2arkAut(NumNot, frbnf, nom, prenom, date_debut): ark = "" frbnf = nettoyageFRBNF(frbnf) url = funcs.url_requete_sru('aut.otherid all "' + frbnf + '"') (test, page) = funcs.testURLetreeParse(url) if (test == True): nb_resultats = int( page.find("//srw:numberOfRecords", namespaces=main.ns).text) if (nb_resultats == 0): ark = oldfrbnf2ark(NumNot, frbnf, nom) elif (nb_resultats == 1): ark = page.find("//srw:recordIdentifier", namespaces=main.ns).text NumNotices2methode[NumNot].append("FRBNF") else: ark = ",".join([ ark.text for ark in page.xpath("//srw:recordIdentifier", namespaces=main.ns) ]) return ark
def ark2metas(ark, unidec=True): recordBNF_url = funcs.url_requete_sru('bib.persistentid any "' + ark + '"') (test, record) = funcs.testURLetreeParse(recordBNF_url) accesspoint = "" accesspoint_compl = "" dates = "" if (test == True): if (record.find("//mxc:datafield[@tag='200']/mxc:subfield[@code='a']", namespaces=main.ns) is not None): accesspoint = record.find( "//mxc:datafield[@tag='200']/mxc:subfield[@code='a']", namespaces=main.ns).text if (record.find("//mxc:datafield[@tag='210']/mxc:subfield[@code='a']", namespaces=main.ns) is not None): accesspoint = record.find( "//mxc:datafield[@tag='210']/mxc:subfield[@code='a']", namespaces=main.ns).text if (record.find("//mxc:datafield[@tag='200']/mxc:subfield[@code='b']", namespaces=main.ns) is not None): accesspoint_compl = record.find( "//mxc:datafield[@tag='200']/mxc:subfield[@code='b']", namespaces=main.ns).text if (record.find("//mxc:datafield[@tag='210']/mxc:subfield[@code='b']", namespaces=main.ns) is not None): accesspoint_compl = record.find( "//mxc:datafield[@tag='210']/mxc:subfield[@code='b']", namespaces=main.ns).text if (record.find("//mxc:datafield[@tag='200']/mxc:subfield[@code='f']", namespaces=main.ns) is not None): dates = record.find( "//mxc:datafield[@tag='200']/mxc:subfield[@code='f']", namespaces=main.ns).text if (record.find("//mxc:datafield[@tag='210']/mxc:subfield[@code='f']", namespaces=main.ns) is not None): dates = record.find( "//mxc:datafield[@tag='210']/mxc:subfield[@code='f']", namespaces=main.ns).text metas = [accesspoint, accesspoint_compl, dates] if (unidec == True): metas = [unidecode(meta) for meta in metas] return metas
def systemid2ark(NumNot, systemid, tronque, nom): url = funcs.url_requete_sru('aut.otherid all "' + systemid + '"') #url = "http://catalogueservice.bnf.fr/SRU?version=1.2&operation=searchRetrieve&query=NumNotice%20any%20%22" + systemid + "%22&recordSchema=InterXMarc_Complet&maximumRecords=1000&startRecord=1" listeARK = [] (test, page) = funcs.testURLetreeParse(url) if (test): for record in page.xpath("//srw:records/srw:record", namespaces=main.ns): ark_current = record.find("srw:recordIdentifier", namespaces=main.ns).text for zone9XX in record.xpath( "srw:recordData/mxc:record/mxc:datafield", namespaces=main.ns): #print(ark_current) tag = zone9XX.get("tag") if (tag[0:1] == "9"): if (zone9XX.find("mxc:subfield[@code='a']", namespaces=main.ns) is not None): if (zone9XX.find("mxc:subfield[@code='a']", namespaces=main.ns).text is not None): if (zone9XX.find( "mxc:subfield[@code='a']", namespaces=main.ns).text == systemid): #print(zone9XX.get("tag")) listeARK.append( comparerAutBnf(NumNot, ark_current, systemid, nom, "Ancien n° notice")) listeARK = ",".join([ark1 for ark1 in listeARK if ark1 != '']) #Si pas de réponse, on fait la recherche SystemID + Nom auteur if (listeARK == ""): listeARK = relancerNNA_nomAuteur(NumNot, systemid, nom) listeARK = ",".join([ark1 for ark1 in listeARK.split(",") if ark1 != '']) #Si à l'issue d'une première requête sur le numéro système dont on a conservé la clé ne donne rien -> on recherche sur le numéro tronqué comme numéro système if (listeARK == "" and tronque == False): systemid_tronque = systemid[0:len(systemid) - 1] systemid2ark(NumNot, systemid_tronque, True, nom) listeARK = ",".join([ark1 for ark1 in listeARK.split(",") if ark1 != '']) return listeARK