Commit 460cd026 authored by Bruno Chareyre's avatar Bruno Chareyre
Browse files

skip item if no authors, generate more variants, impose ordering of types with journals first

parent add9b9b8
Pipeline #68763 passed with stages
in 3 minutes and 32 seconds
......@@ -7,21 +7,22 @@ N_PUBLI_MAX = 100
N_PUBLIS = [3, 5, 10, 15, 50, 100]
MAX_AUTHORS = 3
groups = { 'geo' : { 'Chareyre': '0000-0001-8505-8540',
'Viggiani': '0000-0002-2609-6077',
'DiDona' : '0000-0002-4383-852X',
'Emeriault': '0000-0001-8160-1075',
'Sibille': '0000-0002-3510-3400',
'Villard': '0000-0002-3327-6463',
'Combe': '0000-0002-8633-0793',
'Tengattini': '0000-0003-0320-3340',
'Besuelle': '0000-0001-9586-4888',
'Richefeu': '0000-0002-8897-5499',
'Jenck': '0000-0002-2623-1830',
'Loret': '0000-0002-2622-3179',
'Dano': '0000-0001-8648-7195',
'Daudon': '0000-0003-0233-5608',
}}
groups = { 'geo' : {
'Chareyre': '0000-0001-8505-8540',
'Viggiani': '0000-0002-2609-6077',
'DiDona' : '0000-0002-4383-852X',
'Emeriault': '0000-0001-8160-1075',
'Sibille': '0000-0002-3510-3400',
'Villard': '0000-0002-3327-6463',
'Combe': '0000-0002-8633-0793',
'Tengattini': '0000-0003-0320-3340',
'Besuelle': '0000-0001-9586-4888',
'Richefeu': '0000-0002-8897-5499',
'Jenck': '0000-0002-2623-1830',
'Loret': '0000-0002-2622-3179',
'Dano': '0000-0001-8648-7195',
'Daudon': '0000-0003-0233-5608',
}}
test=None
def html_publi_orcid(publi):
......@@ -29,9 +30,10 @@ def html_publi_orcid(publi):
cite = []
test=publi
# get names
print(len(publi))
authors = [n['credit-name']['value'] for n in publi['contributors']['contributor']]
if not len(authors):
print("no authors for", publi["title"]["title"]["value"])
return '' # if no authors, escape
if len(authors) > MAX_AUTHORS:
authors_displayed = authors[:MAX_AUTHORS]
authors_displayed.append(f'<span class="author"><i>et. al.</i></span>')
......@@ -53,7 +55,6 @@ def html_publi_orcid(publi):
except:
print('journal not found')
journal=''
print(journal)
if len(journal):
cite.append(f'<span class="journal">{journal}</span>')
......@@ -157,7 +158,7 @@ def get_biblio_structure(structure_name, structure_id, n_publi=100):
return files
def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10):
def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10,typesLists = [['journal-article'],['journal-article','conference-paper','book','book-chapter'],['all']]):
BRIDGE_TYPES = {"ART": "journal-article", "COMM": "Conferences", "COUV": "Books", "THESE": "These"}
req = "https://pub.orcid.org/v3.0/"+orcid+"/works"
#req = "http://api.archives-ouvertes.fr/search/?q=(authIdHal_s:{s})&sort={so} desc&rows={n}&fl=*".format(s=idhal, n=N_PUBLI_MAX, so=SORT_BY)
......@@ -180,30 +181,43 @@ def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10):
else:
publis_by_type[type] = [doc]
if i>=N: break
files = []
for listT in typesLists:
if listT[0]=='all':
types = [i for i in publis_by_type.keys()]
file = "{}_all_{}_orcid.html".format(name,N)
else:
types = listT
file = "{}_{}_{}_orcid.html".format(name,"_".join(listT),N)
print(file)
with open(file, 'w') as f:
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
f.write('\t<head>\n')
f.write('\t\t<meta charset="UTF-8">\n')
f.write('\t\t<link rel="stylesheet" href="biblio.css">\n')
f.write('\t</head>\n')
f.write('\t<body class="perso">\n')
for type in types:
if not type in publis_by_type.keys(): continue
publis = publis_by_type[type]
f.write('\t\t<h4>{}</h4>\n'.format(type))
f.write('\t\t<ul>\n')
for publi in publis:
htmlItem = html_publi_orcid(publi)
if not len(htmlItem): continue
f.write('\t\t\t<li>{}</li>\n'.format(htmlItem))
f.write('\t\t</ul>\n')
f.write('\t</body>\n')
f.write('</html>')
files.append(file)
file = "{}_orcid.html".format(name)
print(file)
with open(file, 'w') as f:
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
f.write('\t<head>\n')
f.write('\t\t<meta charset="UTF-8">\n')
f.write('\t\t<link rel="stylesheet" href="biblio.css">\n')
f.write('\t</head>\n')
f.write('\t<body class="perso">\n')
for type, publis in publis_by_type.items():
f.write('\t\t<h4>{}</h4>\n'.format(type))
f.write('\t\t<ul>\n')
for publi in publis:
f.write('\t\t\t<li>{}</li>\n'.format(html_publi_orcid(publi)))
f.write('\t\t</ul>\n')
f.write('\t</body>\n')
f.write('</html>')
return [file]
return files
def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'],['all']]):
def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'],['journal-article','conference-paper','book','book-chapter'],['all']]):
global test
BRIDGE_TYPES = {"ART": "journal-article", "COMM": "Conferences", "COUV": "Books", "THESE": "These"}
publis_by_type = dict()
......@@ -248,11 +262,12 @@ def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'
if i>=8: break
files=[]
for listT in typesLists:
if listT[0]=='all': types = [i for i in publis_by_type.keys()]
else: types = listT
file = "{}_{}_{}_orcid.html".format(groupName,listT[0],str(N))
print("writing ", file)
if listT[0]=='all':
types = [i for i in publis_by_type.keys()]
file = "{}_all_{}_orcid.html".format(groupName,N)
else:
types = listT
file = "{}_{}_{}_orcid.html".format(groupName,"_".join(listT),N)
with open(file, 'w') as f:
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
......@@ -262,6 +277,7 @@ def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'
f.write('\t</head>\n')
f.write('\t<body class="perso">\n')
for type in types:
if not type in publis_by_type.keys(): continue
publis = publis_by_type[type]
test = publis.items()
publis = {k: v for k,v in sorted(publis.items(), key=lambda item: item[1]['time'], reverse=True) }
......@@ -269,8 +285,10 @@ def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'
f.write('\t\t<h4>{}</h4>\n'.format(type))
f.write('\t\t<ul>\n')
for key, publi in publis.items():
print(publi)
f.write('\t\t\t<li>{}</li>\n'.format(html_publi_orcid(publi)))
htmlItem = html_publi_orcid(publi)
if not len(htmlItem): continue
#print(publi)
f.write('\t\t\t<li>{}</li>\n'.format(htmlItem))
f.write('\t\t</ul>\n')
f.write('\t</body>\n')
f.write('</html>')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment