diff --git a/hal/forms.py b/hal/forms.py index c6546134450337c68ad815cdaf55ac684093d507..6076bb1683622a5e3a5d29fbab9871aadcb941c9 100644 --- a/hal/forms.py +++ b/hal/forms.py @@ -12,19 +12,35 @@ class ConnexionForm(forms.Form): username = forms.CharField(required=True, max_length=20, label="Login") password = forms.CharField(required=True, max_length=20, label=("Mot de passe"), widget=forms.PasswordInput()) -class Dblp2halForm(forms.Form): - bib_name_user = forms.CharField(required=True, max_length=40, label="Forme auteur DBLP (*)") + +CHOICES_DEPOT= ( +('NODEPOT', 'Pas de dépôt'), +('PREPROD', 'Dépôt préprod'), +('PRODHAL', 'Dépôt HAL'), +) + +CHOICES_SOURCE_BIBTEX = ( +('DBLP','DBLP'), +) + +CHOICES_SOURCE_TEXT = ( +('RG','Research Gate'), +) + +class Bibtex2halForm(forms.Form): + bib_name_user = forms.CharField(required=True, max_length=40, label="Forme auteur Bibtex (*)") name_user = forms.CharField(required=True, max_length=20, label="Nom chercheur (*)") firstname_user = forms.CharField(required=True, max_length=20, label="Prénom chercheur (*)") - labo_auth_final = forms.CharField(required=True, max_length=20, label="N° de structure (*) (Ex: 490706)") + labo_auth_final = forms.CharField(required=True, max_length=20, label="N° de structure (*) (Ex: 490706)", initial = 490706) id_hal_user = forms.CharField(required=True, max_length=20, label="IdHal chercheur (*)") login_user = forms.CharField(required=True, max_length=20, label="Login HAL chercheur (*)") + choice_source = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_SOURCE_BIBTEX, label="Choix de la source", initial='DBLP' ) + login_depot = forms.CharField(required=True, max_length=20, label="Login HAL référent (*)") passwd_depot = forms.CharField(required=True, max_length=20, label=("Password HAL référent (*)"), widget=forms.PasswordInput()) - bool_depot_preprod = forms.BooleanField(required=False, label="Base de préproduction", initial=False) - bool_depot_prod = forms.BooleanField(required=False, label="Base HAL", initial=False) - + choice_depot = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_DEPOT, label="Choix du dépôt", initial='NODEPOT' ) + domain1 = forms.CharField(required=True, max_length=20, label="Domaine 1 (*)") domain2 = forms.CharField(required=False, max_length=20, label="Domaine 2") domain3 = forms.CharField(required=False, max_length=20, label="Domaine 3") @@ -34,14 +50,16 @@ class Dblp2halForm(forms.Form): bibtex_file = forms.CharField(required=True, label="contenu bibtex", widget=forms.Textarea(attrs={'rows':20, 'cols':90}),) -class DblpXmlForm(forms.Form): +class BibtexXmlForm(forms.Form): bib_name_user = forms.CharField(required=True, max_length=40, label="Forme auteur DBLP (*)") name_user = forms.CharField(required=True, max_length=20, label="Nom chercheur (*)") firstname_user = forms.CharField(required=True, max_length=20, label="Prénom chercheur (*)") - labo_auth_final = forms.CharField(required=True, max_length=20, label="N° de structure (*) (Ex: 490706)") + labo_auth_final = forms.CharField(required=True, max_length=20, label="N° de structure (*) (Ex: 490706)", initial = 490706) id_hal_user = forms.CharField(required=True, max_length=20, label="IdHal chercheur (*)") login_user = forms.CharField(required=True, max_length=20, label="Login HAL chercheur (*)") + choice_source = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_SOURCE_BIBTEX, label="Choix de la source", initial='DBLP' ) + domain1 = forms.CharField(required=True, max_length=20, label="Domaine 1 (*)") domain2 = forms.CharField(required=False, max_length=20, label="Domaine 2") domain3 = forms.CharField(required=False, max_length=20, label="Domaine 3") @@ -61,8 +79,7 @@ class Text2halForm(forms.Form): login_depot = forms.CharField(required=True, max_length=20, label="Login HAL référent (*)") passwd_depot = forms.CharField(required=True, max_length=20, label=("Password HAL référent (*)"), widget=forms.PasswordInput()) - bool_depot_preprod = forms.BooleanField(required=False, label="Base de préproduction", initial=False) - bool_depot_prod = forms.BooleanField(required=False, label="Base HAL", initial=False) + choice_depot = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_DEPOT, label="Choix du dépôt", initial='NODEPOT' ) domain1 = forms.CharField(required=True, max_length=20, label="Domaine 1 (*)") domain2 = forms.CharField(required=False, max_length=20, label="Domaine 2") @@ -100,6 +117,7 @@ class ModifTextForm(forms.Form): text_modif = forms.CharField(required=True, label="contenu texte", widget=forms.Textarea(attrs={'rows':20, 'cols':90}),) class TextFromRG(forms.Form): - text_modif = forms.CharField(required=True, label="contenu Research Gate", widget=forms.Textarea(attrs={'rows':20, 'cols':90}),) + choice_source = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_SOURCE_TEXT, label="Choix de la source", initial='RG' ) + text_modif = forms.CharField(required=True, label="contenu texte", widget=forms.Textarea(attrs={'rows':20, 'cols':90}),) diff --git a/hal/scripts_bibtex.py b/hal/scripts_bibtex.py new file mode 100644 index 0000000000000000000000000000000000000000..c38f3de3d5f9bc2528f4495614efd30ab2abcf19 --- /dev/null +++ b/hal/scripts_bibtex.py @@ -0,0 +1,443 @@ +#!/usr/bin/python +#-*- coding: utf-8 -*- + +from __future__ import unicode_literals +import requests +import csv + +# lib XML +from lxml import etree + +# lib bibtex +import bibtexparser +from bibtexparser.bparser import BibTexParser +from bibtexparser.customization import homogenize_latex_encoding +from bibtexparser.customization import convert_to_unicode + +from create_xml2hal import createXml_sendHal, create_single_xml + +################# +## VARIABLES +################# + + +# Fichier CSV en sortie +file_publis_csv = "all_csv.csv" + + +######################################################################################################################################## +######################################################################################################################################## +########## SCRIPT PRINCIPAL +######################################################################################################################################## +######################################################################################################################################## + +''' +def get_info_from_proceeding(crossref, bib_database) : + #global bib_database + list_info = [] + for entrycrossref in bib_database.entries : + if entrycrossref['ENTRYTYPE']=='proceedings' : + if entrycrossref['ID'] == crossref : + print ("CROSSREF") + #print (" TITLE : ", entrycrossref['title']) + #print (" PUBLISHER : ", entrycrossref['publisher']) + result = entrycrossref['title'] + return result +''' + +def script_bibtex_2_hal (bibtex_file, bib_name_user, name_user, firstname_user, labo_auth_final, id_hal_user, login_user, listdomains, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod, single, source_bibtex): + ''' + take bibtex file and some values in entry and parse the bibtex to get info upon publications + + if the bool 'single' == False -> bibtex file has many publications, call createXml_sendHal (create XML and deposit) return a lis of results + if the bool 'single' == True -> bibtex file has one publication, call create_single_xml (post single XML no deposit) return the XML in string + ''' + resultat = "" + problemes_url = "" + problemes_doublon = "" + problemes_depot = "" + depots = "" + reponse_single_xml = "" + + ################################### + ###### COMPTEURS + ################################### + + cnt_article = 0 + cnt_inproceeding = 0 + cnt_proceeding = 0 + cnt_incollection = 0 + cnt_book = 0 + cnt_total = 0 + cnt_phdthesis = 0 + + # errors bibtex + cnt_error_auth = 0 + cnt_error_title = 0 + cnt_error_jrn = 0 + cnt_error_vol = 0 + cnt_error_numb = 0 + cnt_error_pages = 0 + cnt_error_year_art = 0 + cnt_error_doi = 0 + cnt_error_booktitle = 0 + cnt_error_pages = 0 + cnt_error_year_inp = 0 + cnt_error_crossref = 0 + cnt_error_publisher = 0 + cnt_error_editor = 0 + cnt_error_idcrossref = 0 + cnt_error_publisher_p = 0 + cnt_error_editor_p = 0 + + list_pub_csv = [] + + # une participation a une conf (inproceeding) peut avoir une crossref reliee a une proceeding qui est une conf, celle ci + # se trouve en fin du doc bibtex donc -> + # on cherche crossref dans inproceeding, si on le trouve aller le chercher en bas, sinon chercher editor et publier directement dans inproceeding + # car certains chercheurs peuvent creer leur bibtex comme ceci + + #bibtex_file = bibtex_file.encode("utf-8") + print (bibtex_file) + + parser = BibTexParser() + parser.ignore_nonstandard_types = False + parser.homogenize_fields = False + parser.common_strings = False + parser.customization = convert_to_unicode + bib_database = bibtexparser.loads(bibtex_file, parser = parser) + ''' + parser = BibTexParser() + parser.customization = convert_to_unicode + bib_database = bibtexparser.load(bibtex_file, parser=parser) + ''' + + # list_acronym_country -> nom du pays en anglais majuscule , acronyme du pays + list_acronym_country = [] + with open('hal/countries.csv', 'rb') as csvfile: + delim = str(':') + quotech = str('|') + list_countries = csv.reader(csvfile, delimiter=delim, quotechar=quotech) + for row in list_countries: + list_acronym_country.append((row[1],row[0])) + + + for entry in bib_database.entries : + # initialize entries + type_publi ="" + numero = "" + language = "en" + title = "" + conf="" + nb_pages="" + volume = "" + town="" + country="" + country_acr="XX" + year = 0 + doi_value = "" + publisher_book = "" + editor_book = "" + + # Recup type publi, numero, language + if entry['ENTRYTYPE']=='article' : + cnt_article +=1 + type_publi = "ART" + numero = "RI"+str(cnt_article) + language = "en" + + if entry['ENTRYTYPE']=='inproceedings' : + cnt_inproceeding +=1 + type_publi = "COMM" + numero = "CI"+str(cnt_inproceeding) + language = "en" + + if entry['ENTRYTYPE']=='book' : + cnt_book +=1 + type_publi = "OUV" + numero = "O"+str(cnt_book) + language = "en" + + # Recup title and format + title = entry['title'] + title = title.replace("\n"," ") + title = title.replace("\\emph","") + + # get authors according to source_bibtex + listauthors = [] + if source_bibtex == "DBLP" : + try : + #print ("AUTHOR:"+entry['author']) + authors = entry['author'] + list_authors_mix = authors.split("\n") + for auth in list_authors_mix : + lab_struct = "" + #print ("TEST name_user "+name_user+" - auth "+auth) + + if name_user in auth : + print ("Script_DBLP Match form_author DBLP") + auth = firstname_user+" "+name_user + lab_struct = labo_auth_final + if auth[-4:] == " and" : + auth = auth[:-4] + auth_full = auth.split(" ") + prenom = auth_full[0] + prenom = prenom.encode('utf-8') + nom = auth_full[-1] + nom = nom.encode('utf-8') + #print ("Script_dblp "+"author "+auth.encode('utf-8')+ " - prenom "+ prenom.encode('utf-8')+ " - nom "+nom.encode('utf-8')+ str(type(auth.encode('utf-8')))) + listauthors.append((nom,prenom,lab_struct)) + except KeyError : + cnt_error_auth+=1 + + # if source_bibtex == "..." : + + # Get journal for ARTICLES + if type_publi == "ART" : + try : + conf = entry['journal'] + conf = conf.replace("\n"," ") + except KeyError : + cnt_error_jrn+=1 + + # Get conf for COMM, split entry with ',' , first occurence is conf name + # then search country from CSV in other occurences and if found, get previous occurence to get town (except USA previuous previous occurence) + if type_publi == "COMM" : + try : + booktitle = entry['booktitle'] + conf_all = booktitle.split(",") + conf = conf_all[0] + conf = conf.replace("\n"," ") + conf = conf.replace("\\(^\\mboxth\\)","th") + conf = conf.replace("\\(^\\mboxe\\)","e") + prev_conf_elmt = "" + prev_prev_conf_elmt = "" + for conf_elmt in conf_all : + conf_elmt = conf_elmt.strip() + for csv_country in list_acronym_country : + if conf_elmt.upper() == csv_country[0] : + if csv_country[0] == "USA" : + prev_prev_conf_elmt = prev_prev_conf_elmt.replace("\n"," ") + town = prev_prev_conf_elmt + country_acr = csv_country[1] + country = csv_country[0] + + else : + prev_conf_elmt = prev_conf_elmt.replace("\n"," ") + town = prev_conf_elmt + country_acr = csv_country[1] + country = csv_country[0] + + prev_prev_conf_elmt = prev_conf_elmt + prev_conf_elmt = conf_elmt + + except KeyError : + cnt_error_booktitle+=1 + + # get volume + try : + volume = entry['volume'] + except KeyError : + cnt_error_vol+=1 + + # get nb_pages + try : + nb_pages = entry['pages'] + except KeyError : + cnt_error_pages+=1 + + # get Year + try : + year = entry['year'] + except KeyError : + cnt_error_year_art+=1 + + # get DOI + try : + doi_value = entry['doi'] + except KeyError : + cnt_error_doi+=1 + + + if (type_publi == "COMM") or (type_publi == "BOOK") : + # get Publisher + try : + publisher_book = entry['publisher'] + except KeyError : + cnt_error_publisher+=1 + + # get Editor + try : + editor_book = entry['editor'] + except KeyError : + cnt_error_editor+=1 + + + # Test value "single" + # if false -> call createXml_sendHal (create XML and deposit) + # if true -> call create_single_xml (build XML without creation, no deposit) + if (type_publi == "ART") or (type_publi == "COMM") or (type_publi == "OUV") : + if single == False : + + action_todo="" + + # Verification que la publi n'existe pas deja dans HAL + # pour un meilleur matching, titre en minuscule et recherche par le champ title_t (sans casse ni accent) + title_low = title.lower() + url_request = "https://api.archives-ouvertes.fr/search/?q=title_t:\"{0}\"&fl=uri_s,halId_s,authFullName_s,authIdHal_s,title_s&wt=json".format(title_low) + + req = requests.get(url_request) + json = "" + try : + json = req.json() + except ValueError : + print ("PROBLEME VALUEERROR") + try : + if json is not "" : + result = json['response']['docs'] + + # si un resultat est trouve, recup authors et URI pour affichage dans 'resultat', action_todo = "E" + if (len(result) == 1 ) : + all_auth = "" + try : + tous_authors = result[0]["authFullName_s"] + for auth in tous_authors: + all_auth = all_auth + auth+"-" + except KeyError, e : + print ("error print authors existing publi") + resultat = resultat + "num. "+numero+" - "+result[0]["uri_s"]+" - auteurs:"+all_auth+"<br/>" + action_todo = "E" + + # si plusieurs resultats trouves, recup URI pour affichage dans 'problemes_doublon', action_todo = "2" + if (len(result) >1 ) : + problemes_doublon = problemes_doublon + "num. "+numero+" - URLS "+result[0]["uri_s"]+" "+result[1]["uri_s"]+"<br/>" + action_todo = "2" + + # Si aucun resultat on peut deposer, action_todo = "D" + if (len(result) == 0 ) : + action_todo = "D" + result = False + accept_depot = True + + # Si caracteres incoherents (issus de DBLP) dans le titre -> pas de depot -> problemes_depot + if ("\\(^\\mbox" in title) : + print("-----------------> MBOX") + accept_depot = False + result = False + + title = title.encode("utf-8") + conf = conf.encode("utf-8") + town = town.encode("utf-8") + editor_book = editor_book.encode("utf-8") + + if accept_depot == True : + result = createXml_sendHal(numero, listauthors, language, title, conf, nb_pages, year, listdomains, type_publi, town, country, country_acr,doi_value, editor_book, volume, name_user, labo_auth_final, id_hal_user, login_user, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod) + + # methode createXml_sendHal renvoie true -> depot HAL ou preprod OK + if result == True : + depots = depots + "num. "+numero+" au titre "+title.decode("utf-8")+" deposee dans HAL<br/>" + # methode createXml_sendHal renvoie true -> pb depot HAL ou preprod ou pas de depot demande + if result == False : + problemes_depot = problemes_depot + "num. "+numero+" au titre "+title.decode("utf-8")+" a un probleme de depot<br/>" + else : + # pb de lecture json, pas depot -> problemes_url + action_todo = "P" + problemes_url = problemes_url + "num. "+numero+" au titre "+title.decode("utf-8")+"<br/>" + except KeyError : + # pb de lecture json, pas depot -> problemes_url + action_todo = "P" + problemes_url = problemes_url + "num. "+numero+" au titre "+title.decode("utf-8")+"<br/>" + + # Creation du CSV qui sera renvoye et affiche + authors = authors.replace(" and",", ") + list_pub_csv.append((numero,authors,title,conf,nb_pages, volume,year, type_publi, action_todo, town, country, country_acr, language)) + + + elif single == True : + title = title.encode("utf-8") + conf = conf.encode("utf-8") + town = town.encode("utf-8") + editor_book = editor_book.encode("utf-8") + login_user = login_depot + reponse_single_xml = create_single_xml(listauthors, language, title, conf, nb_pages, year, listdomains, type_publi, town, country, country_acr, doi_value, editor_book, volume, name_user, labo_auth_final, id_hal_user, login_user) + + # ------------------END LOOP ----------------- + cnt_total+=1 + + ######################## + ####### ECRITURE RESULTATS -> list_resultats + print ("list_pub_csv length :",cnt_total) + + list_resultats=[] + for pub in list_pub_csv : + allauth = pub[1] + allauth = allauth.replace("\n","") + title = pub[2]#.decode("utf-8") + conf = pub[3]#.decode("utf-8") + ville = pub[9]#.decode("utf-8") + + list_resultats.append((str(pub[0]),allauth,title,conf,str(pub[4]),str(pub[5]),str(pub[6]),str(pub[7]),str(pub[8]),ville,str(pub[10]),str(pub[11]),str(pub[12]))) + + cnt_nb_publis = cnt_article + cnt_inproceeding + cnt_book + cnt_incollection + cnt_phdthesis + + list_resultats.append(("RESULTATS","nombre de publis",str(cnt_nb_publis),"","","","","","","","","","")) + list_resultats.append(("RESULTATS","publis deja presentes dans HAL",resultat,"","","","","","","","","","")) + list_resultats.append(("RESULTATS","depots",depots,"","","","","","","","","","")) + list_resultats.append(("RESULTATS","problemes de depot",problemes_depot,"","","","","", "","","","","")) + list_resultats.append(("RESULTATS","problemes de doublon",problemes_doublon,"","","","", "","","","","","")) + list_resultats.append(("RESULTATS","problemes url",problemes_url,"","","","","","","","","","")) + + print ("####### RESULTATS PARSING BIBTEX ########") + print ("cnt_article ", cnt_article) + print ("cnt_inproceeding ", cnt_inproceeding) + print ("cnt_proceeding ", cnt_proceeding) + print ("cnt_incollection ", cnt_incollection) + print ("cnt_book ", cnt_book) + print ("cnt_phdthesis ", cnt_phdthesis) + print ("cnt_total ", cnt_total) + + print ("ERROR Author", cnt_error_auth) + print ("ERROR Title", cnt_error_title) + + print ("-------ERRORS ARTICLE------") + print ("cnt_error_jrn",cnt_error_jrn) + print ("cnt_error_vol",cnt_error_vol) + print ("cnt_error_numb",cnt_error_numb) + print ("cnt_error_pages",cnt_error_pages) + print ("cnt_error_year_art",cnt_error_year_art) + print ("cnt_error_doi",cnt_error_doi) + + print ("-------ERRORS INPROCEEDINGS------") + print ("cnt_error_booktitle:",cnt_error_booktitle) + print ("cnt_error_pages:",cnt_error_pages) + print ("cnt_error_year_inp:",cnt_error_year_inp) + print ("cnt_error_crossref:",cnt_error_crossref) + print ("cnt_error_publisher:",cnt_error_publisher) + print ("cnt_error_editor:",cnt_error_editor) + + print ("-------ERRORS PROCEEDINGS------") + print ("cnt_error_idcrossref:",cnt_error_idcrossref) + + print ("#########################################") + + print ("######## RESULTATS XML + DEPOTS ##########") + print ("RESULTATS existants") + print (resultat.encode("utf-8")) + print ("------------------") + print ("DEPOTS effectues") + print (depots.encode("utf-8")) + print ("------------------") + print ("PROBLEMES DEPOTS") + print (problemes_depot.encode("utf-8")) + print ("------------------") + print ("PROBLEMES DOUBLONS") + print (problemes_doublon.encode("utf-8")) + print ("------------------") + print ("PROBLEMES URL") + print (problemes_url.encode("utf-8")) + + + if single == False : + return list_resultats + if single == True : + return reponse_single_xml diff --git a/hal/templates/base.html b/hal/templates/base.html index 229b192531ffcfa584b9395cf32366e948fa4d87..54ea2d6d8d7ab4e19decaf29ac6fee035d0fe289 100644 --- a/hal/templates/base.html +++ b/hal/templates/base.html @@ -42,10 +42,10 @@ {% if user.is_authenticated %} <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">DBLP</a> + <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Bibtex</a> <div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 39px, 0px);"> - <a class="dropdown-item" href="{% url "dblp2hal" %}">Dblp_2_Hal</a> - <a class="dropdown-item" href="{% url "dblpxml" %}">Create XML</a> + <a class="dropdown-item" href="{% url "bibtex2hal" %}">Bibtex_2_Hal</a> + <a class="dropdown-item" href="{% url "bibtexxml" %}">Create XML</a> </div> </li> @@ -55,7 +55,7 @@ <a class="dropdown-item" href="{% url "text2hal" %}">Text_2_Hal</a> <a class="dropdown-item" href="{% url "textxml" %}">Create XML</a> <a class="dropdown-item" href="{% url "textmodif" %}">Modify Text</a> - <a class="dropdown-item" href="{% url "text_format_rg" %}">Format text from RG</a> + <a class="dropdown-item" href="{% url "text_format" %}">Format text</a> </div> </li> <li class="nav-item"> diff --git a/hal/templates/hal/bibtex2hal.html b/hal/templates/hal/bibtex2hal.html new file mode 100644 index 0000000000000000000000000000000000000000..547584ad3e4a03b8cfbc93e9a78d293b829b6dd2 --- /dev/null +++ b/hal/templates/hal/bibtex2hal.html @@ -0,0 +1,263 @@ +{% extends "base.html" %} +{% load static %} +{% load staticfiles %} +{% load bootstrap3 %} +{% load bootstrap_themes %} + +{% block head %} +<head> + <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> + <link rel="shortcut icon" href="{% static 'imgsite/favicon.ico' %}"> + <title>Outils HAL</title> + +</head> +{% endblock %} + +{% block content %} +<h3>Bibtex to HAL</h3> + <br/> + {% if user.is_authenticated %} + <p align="left">Remplissez les données demandées ci-dessous + <br/> + Tous les champs sont requis + <br/> + Dans un premier temps, simulez le dépôt en laissant les champs "dépôt préprod" et "dépôt prod" décochés + <br/> + Copiez-collez le contenu de votre fichier bibtex dans la zone prévue</p> + + <div class="well bs-component"> + <form action="{% url "bibtex2hal" %}" method="post"> + {% csrf_token %} + + <div class="row"> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Auteur</h3> + </div> + </div> + + <!-- 1e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.bib_name_user.errors }} + {{ form.bib_name_user.label_tag }}<br/> + {{ form.bib_name_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.name_user.errors }} + {{ form.name_user.label_tag }}<br/> + {{ form.name_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.firstname_user.errors }} + {{ form.firstname_user.label_tag }}<br/> + {{ form.firstname_user }} + </div> + </div> + <!-- 2e ligne --> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.login_user.errors }} + {{ form.login_user.label_tag }}<br/> + {{ form.login_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.id_hal_user.errors }} + {{ form.id_hal_user.label_tag }}<br/> + {{ form.id_hal_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.labo_auth_final.errors }} + {{ form.labo_auth_final.label_tag }}<br/> + {{ form.labo_auth_final }} + </div> + <br/> + </div> + + + <!-- 3e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain1.errors }} + {{ form.domain1.label_tag }}<br/> + {{ form.domain1 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain2.errors }} + {{ form.domain2.label_tag }}<br/> + {{ form.domain2 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain3.errors }} + {{ form.domain3.label_tag }}<br/> + {{ form.domain3 }} + </div> + </div> + + <!-- 4e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain4.errors }} + {{ form.domain4.label_tag }}<br/> + {{ form.domain4 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain5.errors }} + {{ form.domain5.label_tag }}<br/> + {{ form.domain5 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Source</h3> + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + {{ form.choice_source.errors }} + {{ form.choice_source.label_tag }}<br/> + {{ form.choice_source }} + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Déposant</h3> + </div> + </div> + + <!-- 5e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.login_depot.errors }} + {{ form.login_depot.label_tag }}<br/> + {{ form.login_depot }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.passwd_depot.errors }} + {{ form.passwd_depot.label_tag }}<br/> + {{ form.passwd_depot }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.choice_depot.errors }} + {{ form.choice_depot.label_tag }}<br/> + {{ form.choice_depot }} + </div> + </div> + + + <!-- 6e ligne --> + <div class="col-lg-12"> + <br/> + <hr> + <div class="fieldWrapper"> + {{ form.bibtex_file.errors }} + {{ form.bibtex_file.label_tag }}<br/> + {{ form.bibtex_file }} + </div> + </div> + </div> + + + <input type="submit" class="btn btn-primary" value="Submit" /> + </form> + </div> + + <div class="well bs-component"> + <div class="row"> + <div class="col-lg-12"> + <br/> + <b><u>Résultats :</u></b> + {% autoescape off %} + <br/> + <p align="left"> + {{ reponse_to_post }} + </p> + <br/> + {% endautoescape %} + <br/> + </div> + </div> + </div> + + {% if list_to_post|length > 0%} + <table class="table table-striped table-hover "> + <tr> + <th>n°</th> + <th>Auteurs </th> + <th>Titre</th> + <th>Conf</th> + <th>pp </th> + <th>vol</th> + <th>date</th> + <th>type </th> + <th>todo</th> + <th>Ville</th> + <th>pays </th> + <th>acr</th> + <th>lang</th> + </tr> + + {% for pub in list_to_post %} + <tr> + <td>{{ pub.num }}</td> + <td>{{ pub.authors }}</td> + <td>{{ pub.title }}</td> + <td>{{ pub.conf }}</td> + <td>{{ pub.page }}</td> + <td>{{ pub.vol }}</td> + <td>{{ pub.date }}</td> + <td>{{ pub.type }}</td> + <td>{{ pub.todo }}</td> + <td>{{ pub.ville }}</td> + <td>{{ pub.pays }}</td> + <td>{{ pub.acr }}</td> + <td>{{ pub.lang }}</td> + </tr> + {% endfor %} + </table> + {% endif %} + + {% else %} + <h5>Pour faire une demande d'identifiants, envoyer un mail à jessica.leyrit@uca.fr</h5> + <br/> + + {% endif %} + +{% endblock %} diff --git a/hal/templates/hal/bibtexxml.html b/hal/templates/hal/bibtexxml.html new file mode 100644 index 0000000000000000000000000000000000000000..4af806455ddd1a4dafb01155b4639c4b70f84a57 --- /dev/null +++ b/hal/templates/hal/bibtexxml.html @@ -0,0 +1,189 @@ +{% extends "base.html" %} +{% load static %} +{% load staticfiles %} +{% load bootstrap3 %} +{% load bootstrap_themes %} + +{% block head %} +<head> + <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> + <link rel="shortcut icon" href="{% static 'imgsite/favicon.ico' %}"> + <title>Outils HAL</title> +</head> +{% endblock %} + +{% block content %} +<h3>Create XML from Bibtex</h3> + <br/> + {% if user.is_authenticated %} + <p align="left">Remplissez les données demandées ci-dessous + <br/> + Tous les champs sont requis + <br/> + Copiez-collez le contenu de votre fichier bibtex dans la zone prévue</p> + + <div class="well bs-component"> + <form action="{% url "bibtexxml" %}" method="post"> + {% csrf_token %} + + <div class="row"> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Auteur</h3> + </div> + </div> + + <!-- 1e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.bib_name_user.errors }} + {{ form.bib_name_user.label_tag }}<br/> + {{ form.bib_name_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.name_user.errors }} + {{ form.name_user.label_tag }}<br/> + {{ form.name_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.firstname_user.errors }} + {{ form.firstname_user.label_tag }}<br/> + {{ form.firstname_user }} + </div> + </div> + <!-- 2e ligne --> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.login_user.errors }} + {{ form.login_user.label_tag }}<br/> + {{ form.login_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.id_hal_user.errors }} + {{ form.id_hal_user.label_tag }}<br/> + {{ form.id_hal_user }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.labo_auth_final.errors }} + {{ form.labo_auth_final.label_tag }}<br/> + {{ form.labo_auth_final }} + </div> + <br/> + </div> + + <!-- 3e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain1.errors }} + {{ form.domain1.label_tag }}<br/> + {{ form.domain1 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain2.errors }} + {{ form.domain2.label_tag }}<br/> + {{ form.domain2 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain3.errors }} + {{ form.domain3.label_tag }}<br/> + {{ form.domain3 }} + </div> + </div> + + <!-- 4e ligne --> + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain4.errors }} + {{ form.domain4.label_tag }}<br/> + {{ form.domain4 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + {{ form.domain5.errors }} + {{ form.domain5.label_tag }}<br/> + {{ form.domain5 }} + </div> + </div> + + <div class="col-lg-4"> + <div class="fieldWrapper"> + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Source</h3> + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + {{ form.choice_source.errors }} + {{ form.choice_source.label_tag }}<br/> + {{ form.choice_source }} + </div> + </div> + + <!-- 5e ligne --> + <div class="col-lg-12"> + + <div class="fieldWrapper"> + {{ form.bibtex_file.errors }} + {{ form.bibtex_file.label_tag }}<br/> + {{ form.bibtex_file }} + </div> + </div> + </div> + + + <input type="submit" class="btn btn-primary" value="Submit" /> + </form> + </div> + + <div class="well bs-component"> + <div class="row"> + <div class="col-lg-12"> + <br/> + <b><u>Résultats :</u></b> + + <br/> + + <pre>{{ reponse_to_post }}</pre> + + <br/> + + <br/> + </div> + </div> + </div> + + + {% else %} + <h5>Pour faire une demande d'identifiants, envoyer un mail à jessica.leyrit@uca.fr</h5> + <br/> + + {% endif %} + +{% endblock %} diff --git a/hal/templates/hal/text2hal.html b/hal/templates/hal/text2hal.html index e3461fe0d0321816b7e18298002b6b177593301b..391d303002a816263b7848518f7fc127241dd4fa 100644 --- a/hal/templates/hal/text2hal.html +++ b/hal/templates/hal/text2hal.html @@ -183,38 +183,15 @@ <div class="col-lg-4"> <div class="fieldWrapper"> + {{ form.choice_depot.errors }} + {{ form.choice_depot.label_tag }}<br/> + {{ form.choice_depot }} </div> </div> - <!-- 6e ligne --> - <br/> - <div class="col-lg-4"> - <div class="fieldWrapper"> - <br/><br/> - <h3>Dépôts</h3> - </div> - </div> - - - <div class="col-lg-4"> - <div class="fieldWrapper"> - <br/><br/> - {{ form.bool_depot_preprod.errors }} - {{ form.bool_depot_preprod.label_tag }}<br/> - {{ form.bool_depot_preprod }} - </div> - </div> - - <div class="col-lg-4"> - <div class="fieldWrapper"> - <br/><br/> - {{ form.bool_depot_prod.errors }} - {{ form.bool_depot_prod.label_tag }}<br/> - {{ form.bool_depot_prod }} - </div> - </div> + - <!-- 7e ligne --> + <!-- 6e ligne --> <div class="col-lg-12"> <br/> <div class="fieldWrapper"> diff --git a/hal/templates/hal/text_format.html b/hal/templates/hal/text_format.html new file mode 100644 index 0000000000000000000000000000000000000000..16522f201ade48197a4247ed095763ff1ef774fc --- /dev/null +++ b/hal/templates/hal/text_format.html @@ -0,0 +1,93 @@ +{% extends "base.html" %} +{% load static %} +{% load staticfiles %} +{% load bootstrap3 %} +{% load bootstrap_themes %} + +{% block head %} +<head> + <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> + <link rel="shortcut icon" href="{% static 'imgsite/favicon.ico' %}"> + <title>Outils HAL</title> +</head> +{% endblock %} + +{% block content %} +<h3>Format Text</h3> + <br/> + {% if user.is_authenticated %} + <p align="left">Copiez-collez le contenu d'une source (au format texte) dans la zone prévue<br/> + <br/> + Pour un export d'un <b>CV par Research Gate</b>, par exemple :<br/> + + <i>Azouz Nesrine, Henri Pierreval: Adaptive smart card-based pull control systems in context-aware manufacturing systems: Training a neural network through multi-objective simulation optimization. Applied Soft Computing 11/2018;, DOI:10.1016/j.asoc.2018.10.051 + <br/> + Sana-Kouki Amri, Saber Darmoul, Sonia Hajri-Gabouj, Henri Pierreval: Risk issues in facility layout design. Sixth International Conference on Industrial Engineering and Operations Management, IEOM’2016, Kuala Lumpur, Malaysia; 03/2016 + <br/> + FEYZIOGLU O, PIERREVAL H: Hybrid organization of functional departments and manufacturing cells in the presence of imprecise data. International Journal of Production Research 01/2009; 47(2):343-368., DOI:10.1080/00207540802425898 + <br/> + </i> + </p> + + + <div class="well bs-component"> + <form action="{% url "text_format" %}" method="post"> + {% csrf_token %} + + <div class="row"> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + <h3>Source</h3> + </div> + </div> + + <div class="col-lg-12"> + <div class="fieldWrapper"> + {{ form.choice_source.errors }} + {{ form.choice_source.label_tag }}<br/> + {{ form.choice_source }} + </div> + </div> + + <!-- 6e ligne --> + <div class="col-lg-12"> + <div class="fieldWrapper"> + {{ form.text_modif.errors }} + <h4>{{ form.text_modif.label_tag }}</h4> + {{ form.text_modif }} + </div> + </div> + </div> + + <input type="submit" class="btn btn-primary" value="Submit" /> + </form> + </div> + + <div class="well bs-component"> + <div class="row"> + <div class="col-lg-12"> + <br/> + <b><u>Résultats :</u></b> + + <br/> + +<pre> +{{ reponse_to_post }} +</pre> + + <br/> + + <br/> + </div> + </div> + </div> + + + {% else %} + <h5>Pour faire une demande d'identifiants, envoyer un mail à jessica.leyrit@uca.fr</h5> + <br/> + + {% endif %} + +{% endblock %} diff --git a/hal/urls.py b/hal/urls.py index 499f32977101f305df7980435ea69da14d5dc715..2255940537281ad06899147f9e0c5a5eba0e1291 100644 --- a/hal/urls.py +++ b/hal/urls.py @@ -8,12 +8,12 @@ urlpatterns = [ url(r'^connexion$', views.connexion, name='connexion'), url(r'^deconnexion$', views.deconnexion, name='deconnexion'), url(r'^blog$', views.article_blog, name='blog'), - url(r'^dblp2hal$', views.dblp2hal, name='dblp2hal'), - url(r'^dblpxml$', views.dblpxml, name='dblpxml'), + url(r'^bibtex2hal$', views.bibtex2hal, name='bibtex2hal'), + url(r'^bibtexxml$', views.bibtexxml, name='bibtexxml'), url(r'^text2hal$', views.text2hal, name='text2hal'), url(r'^textxml$', views.textxml, name='textxml'), url(r'^textmodif$', views.textmodif, name='textmodif'), - url(r'^text_format_rg$', views.text_format_rg, name='text_format_rg'), + url(r'^text_format$', views.text_format, name='text_format'), url(r'^aide$', views.aide, name='aide'), ] diff --git a/hal/views.py b/hal/views.py index c5f698889e29b3d511e18d8f3db0b1b6dc6a3f94..91b98203767a86b95cc258d0dd19202ad22bb5ed 100644 --- a/hal/views.py +++ b/hal/views.py @@ -7,9 +7,9 @@ from django.contrib.auth.backends import ModelBackend from django.contrib.auth import authenticate, login from django.contrib.auth.views import logout -from forms import ConnexionForm, Dblp2halForm, Text2halForm, DblpXmlForm, TextXmlForm, ModifTextForm,TextFromRG +from forms import ConnexionForm, Bibtex2halForm, Text2halForm, BibtexXmlForm, TextXmlForm, ModifTextForm,TextFromRG -from scripts_dblp import script_dblp_2_hal +from scripts_bibtex import script_bibtex_2_hal from scripts_text import script_text_2_hal @@ -80,16 +80,16 @@ class PubliDescribe(): self.lang = "" ################################################################################################################################## -## DBLP2HAL ###################################################################################################################### +## BIBTEX2HAL ###################################################################################################################### ################################################################################################################################## -def dblp2hal(request): +def bibtex2hal(request): ''' treats a bibtex file and some variables give a table of data (parsed bibtex file) and results of HAL depot ''' reponse = "" - form = Dblp2halForm(request.POST or None) + form = Bibtex2halForm(request.POST or None) if form.is_valid(): # get data from form @@ -104,12 +104,28 @@ def dblp2hal(request): domain3 = form.cleaned_data['domain3'] domain4 = form.cleaned_data['domain4'] domain5 = form.cleaned_data['domain5'] + + choice_source = form.cleaned_data['choice_source'] login_depot = form.cleaned_data['login_depot'] passwd_depot = form.cleaned_data['passwd_depot'] - bool_depot_preprod = form.cleaned_data['bool_depot_preprod'] - bool_depot_prod = form.cleaned_data['bool_depot_prod'] + #bool_depot_preprod = form.cleaned_data['bool_depot_preprod'] + #bool_depot_prod = form.cleaned_data['bool_depot_prod'] + choice_depot = form.cleaned_data['choice_depot'] bibtex_file = form.cleaned_data['bibtex_file'] + + bool_depot_preprod = False + bool_depot_prod = False + + # recup du type de depot + if choice_depot == 'PREPROD' : + print ("Views.py depot preprod") + bool_depot_preprod == True + if choice_depot == 'PRODHAL' : + print ("Views.py depot prod") + bool_depot_prod == True + + print ("choice_source ",choice_source) # single = False -> ask to deposit many publications single = False @@ -129,7 +145,7 @@ def dblp2hal(request): listdomains.append(domain5) print ("begin script") - reponse = script_dblp_2_hal(bibtex_file, bib_name_user, name_user, firstname_user, labo_auth_final, id_hal_user, login_user, listdomains, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod, single) + reponse = script_bibtex_2_hal(bibtex_file, bib_name_user, name_user, firstname_user, labo_auth_final, id_hal_user, login_user, listdomains, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod, single, choice_source) # in reponse, there's a table of data coming from bibtex file and some results (with "RESULTATS" in first column) reponse_to_post = "" @@ -158,15 +174,15 @@ def dblp2hal(request): #result[6],result[7],result[8],result[9],result[10],result[11],result[12],)) #reponse=("reponse HAL") - return render(request, 'hal/dblp2hal.html', locals()) + return render(request, 'hal/bibtex2hal.html', locals()) ################################################################################################################################## -## DBLPXML ###################################################################################################################### +## bibtexXML ###################################################################################################################### ################################################################################################################################## -def dblpxml(request): +def bibtexxml(request): reponse = "" - form = DblpXmlForm(request.POST or None) + form = BibtexXmlForm(request.POST or None) if form.is_valid(): # recup donnees @@ -182,6 +198,8 @@ def dblpxml(request): domain4 = form.cleaned_data['domain4'] domain5 = form.cleaned_data['domain5'] + choice_source = form.cleaned_data['choice_source'] + bibtex_file = form.cleaned_data['bibtex_file'] login_depot = request.user passwd_depot = "" @@ -203,10 +221,10 @@ def dblpxml(request): if domain5 is not "" : listdomains.append(domain5) - reponse_to_post = script_dblp_2_hal(bibtex_file, bib_name_user, name_user, firstname_user, labo_auth_final, id_hal_user, login_user, listdomains, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod, single) + reponse_to_post = script_bibtex_2_hal(bibtex_file, bib_name_user, name_user, firstname_user, labo_auth_final, id_hal_user, login_user, listdomains, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod, single, choice_source) #print (reponse_to_post) - return render(request, 'hal/dblpxml.html', locals()) + return render(request, 'hal/bibtexxml.html', locals()) ################################################################################################################################## @@ -234,9 +252,22 @@ def text2hal(request): login_depot = form.cleaned_data['login_depot'] passwd_depot = form.cleaned_data['passwd_depot'] - bool_depot_preprod = form.cleaned_data['bool_depot_preprod'] - bool_depot_prod = form.cleaned_data['bool_depot_prod'] + #bool_depot_preprod = form.cleaned_data['bool_depot_preprod'] + #bool_depot_prod = form.cleaned_data['bool_depot_prod'] + choice_depot = form.cleaned_data['choice_depot'] text_file = form.cleaned_data['text_file'] + + bool_depot_preprod = False + bool_depot_prod = False + + # recup du type de depot + if choice_depot == 'PREPROD' : + print ("Views.py depot preprod") + bool_depot_preprod == True + if choice_depot == 'PRODHAL' : + print ("Views.py depot prod") + bool_depot_prod == True + labo_auth_final = "struct-"+labo_auth_final @@ -510,123 +541,123 @@ def textmodif(request): ## FORMAT_RG #################################################################################################################### ################################################################################################################################## -def text_format_rg(request): +def text_format(request): reponse = "" form = TextFromRG(request.POST or None) result = "" if form.is_valid(): # recup donnees + choice_source = form.cleaned_data['choice_source'] text_modif = form.cleaned_data['text_modif'] reponse_to_post = text_modif list_publis = reponse_to_post.splitlines() + result = "" - for publi in list_publis : - print ("********************") - #publi = publi[1:] - #print (publi) - x = publi.find(":")#.decode('utf-8') - authors = publi[0:x] - authors = authors.strip() - - rest_publi = publi[x+1:] + # Format text for source Research_Gate + if choice_source == "RG" : + for publi in list_publis : + print ("********************") + #publi = publi[1:] + #print (publi) + x = publi.find(":")#.decode('utf-8') + authors = publi[0:x] + authors = authors.strip() - x = rest_publi.find(".") - title = rest_publi[1:x] - rest_publi = rest_publi[x+1:] - - conf = "" - year = "" - vol = "" - pp = "" - # recherche de l'element mois + / -> 04/ 11/ ... - try : - end_conf = re.findall('\s[0-1][0-9][\/]', rest_publi)[0] - x = rest_publi.find(end_conf) - if x > -1 : - conf = rest_publi[:x] - conf = conf.replace(";","") - conf = conf.strip() - rest_publi = rest_publi[x:] - print ("rest_publi 1 :"+rest_publi) - year = rest_publi[4:] - x = year.find(";") - # si ; apres annee --> article, sinon conf - - if x > -1 : # ARTICLE - year = year[:x] - year = year.replace(",","") - year = year.strip() - rest_publi = rest_publi[x+4:] - print ("rest_publi 2 :"+rest_publi) - - vol = rest_publi - - y = vol.find("DOI") - if y > -1 : - vol = vol[:y] - - y = vol.find(":") - if y > -1 : - vol = vol[:y] - vol = vol.replace(";","") - vol = vol.strip() - rest_publi = rest_publi[y+1:] - print ("rest_publi 3 :"+rest_publi) - pp = rest_publi - z = pp.find("DOI") - pp = pp[:z-1] - pp = pp.replace(".","") - pp = pp.replace(",","") - pp = pp.strip() - rest_publi = rest_publi[z:] - rest_publi = rest_publi.replace("DOI","doi") - - print ("rest_publi 4 :"+rest_publi) - - elif y == -1 : - print ("--> --> --> NO PAGES rest_publi 3 :"+rest_publi) - y = vol.find(".") - vol = vol[:y] - vol = vol.replace(";","") - vol = vol.replace(",","") - rest_publi = rest_publi[y+2:] - - print ("year "+year + " vol "+vol+ " pages "+pp + " rest_pub "+ rest_publi) - - elif x == -1 : # CONF - end_year = re.findall('\D', year)[0] - x = year.find(end_year) - - year = year[:x] - print ("YEAR "+year) - - - - #print ("rest_publi "+rest_publi) - except IndexError : - print ("IndexError "+title) - - #x = publi.find("-")#.decode('utf-8') - #numero = publi[0:x] - end_string_vol_pages = "" - if vol is not "" : - end_string_vol_pages = end_string_vol_pages+", Vol. "+vol - if pp is not "" : - end_string_vol_pages = end_string_vol_pages+", pp. "+pp - #print ("end_string_vol_pages "+end_string_vol_pages) - result = result+authors+","+"\""+title+"\","+conf+", "+year+end_string_vol_pages+", "+rest_publi+"\n "# +rest_publi - + rest_publi = publi[x+1:] + + x = rest_publi.find(".") + title = rest_publi[1:x] + rest_publi = rest_publi[x+1:] + + conf = "" + year = "" + vol = "" + pp = "" + # recherche de l'element mois + / -> 04/ 11/ ... + try : + end_conf = re.findall('\s[0-1][0-9][\/]', rest_publi)[0] + x = rest_publi.find(end_conf) + if x > -1 : + conf = rest_publi[:x] + conf = conf.replace(";","") + conf = conf.strip() + rest_publi = rest_publi[x:] + print ("rest_publi 1 :"+rest_publi) + year = rest_publi[4:] + x = year.find(";") + # si ; apres annee --> article, sinon conf + + if x > -1 : # ARTICLE + year = year[:x] + year = year.replace(",","") + year = year.strip() + rest_publi = rest_publi[x+4:] + print ("rest_publi 2 :"+rest_publi) + + vol = rest_publi + + y = vol.find("DOI") + if y > -1 : + vol = vol[:y] + + y = vol.find(":") + if y > -1 : + vol = vol[:y] + vol = vol.replace(";","") + vol = vol.strip() + rest_publi = rest_publi[y+1:] + print ("rest_publi 3 :"+rest_publi) + pp = rest_publi + z = pp.find("DOI") + pp = pp[:z-1] + pp = pp.replace(".","") + pp = pp.replace(",","") + pp = pp.strip() + rest_publi = rest_publi[z:] + + + print ("rest_publi 4 :"+rest_publi) + + elif y == -1 : + print ("--> --> --> NO PAGES rest_publi 3 :"+rest_publi) + y = vol.find(".") + vol = vol[:y] + vol = vol.replace(";","") + vol = vol.replace(",","") + rest_publi = rest_publi[y+2:] + + rest_publi = rest_publi.replace("DOI:","doi:") + + print ("year "+year + " vol "+vol+ " pages "+pp + " rest_pub "+ rest_publi) + + elif x == -1 : # CONF + end_year = re.findall('\D', year)[0] + x = year.find(end_year) + + year = year[:x] + print ("YEAR "+year) + + #print ("rest_publi "+rest_publi) + except IndexError : + print ("IndexError "+title) + + #x = publi.find("-")#.decode('utf-8') + #numero = publi[0:x] + end_string_vol_pages = "" + if vol is not "" : + end_string_vol_pages = end_string_vol_pages+", Vol. "+vol + if pp is not "" : + end_string_vol_pages = end_string_vol_pages+", pp. "+pp + #print ("end_string_vol_pages "+end_string_vol_pages) + result = result+authors+","+"\""+title+"\","+conf+", "+year+end_string_vol_pages+", "+rest_publi+"\n"# +rest_publi - #print (authors+","+"\""+title+"\""+rest_publi) - #listpub.append((authors, title, rest_publi)) - #result = result.replace("\n\n","\n") print (result) reponse_to_post = result - return render(request, 'hal/text_format_rg.html', locals()) + return render(request, 'hal/text_format.html', locals())