Commit add9b9b8 authored by Bruno Chareyre's avatar Bruno Chareyre
Browse files

code cleaning

parent 256942c5
Pipeline #68741 passed with stages
in 3 minutes and 31 seconds
......@@ -30,7 +30,6 @@ def html_publi_orcid(publi):
test=publi
# get names
print(len(publi))
print(publi)
authors = [n['credit-name']['value'] for n in publi['contributors']['contributor']]
if len(authors) > MAX_AUTHORS:
......@@ -38,7 +37,6 @@ def html_publi_orcid(publi):
authors_displayed.append(f'<span class="author"><i>et. al.</i></span>')
else:
authors_displayed = authors
print(authors_displayed)
cite.append(f'<span class="authors" title="">{", ".join(authors_displayed)}</span>')
# get title and url
......@@ -176,18 +174,12 @@ def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10):
doc = requests.get('http://pub.orcid.org/'+work['path'],
headers={'Accept':'application/orcid+json'}).json()
type = BRIDGE_TYPES.get(work.get("type")) if BRIDGE_TYPES.get(work.get("type")) is not None else work.get("type")
print("type",type)
print("type",type,"found for",name)
if type in publis_by_type:
publis_by_type[type].append(doc)
else:
publis_by_type[type] = [doc]
if i>=N: break
#try:
#print(doc['citation']['citation-value'])
#except:
#print('http://pub.orcid.org/'+work['path'], "FAILED\n",'http://pub.orcid.org/'+doc['title']['title']['value'])
file = "{}_orcid.html".format(name)
print(file)
......@@ -254,20 +246,13 @@ def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'
publis_by_type[type] = dict()
publis_by_type[type][key] = doc
if i>=8: break
#try:
#print(doc['citation']['citation-value'])
#except:
#print('http://pub.orcid.org/'+work['path'], "FAILED\n",'http://pub.orcid.org/'+doc['title']['title']['value'])
print("NAME: ",groupName)
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(file)
print("writing ", file)
with open(file, 'w') as f:
f.write('<!DOCTYPE html>\n')
f.write('<html>\n')
......@@ -278,13 +263,6 @@ def get_biblio_group_orcid(groupName='geo',N=20,typesLists = [['journal-article'
f.write('\t<body class="perso">\n')
for type in types:
publis = publis_by_type[type]
#for type, publis in publis_by_type.items():
print("Type",type,publis)
#>>> x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
#>>> {k: v for k, v in sorted(x.items(), key=lambda item: item[1])}
#{0: 0, 2: 1, 1: 2, 4: 3, 3: 4}
# sort by time
test = publis.items()
publis = {k: v for k,v in sorted(publis.items(), key=lambda item: item[1]['time'], reverse=True) }
......@@ -341,6 +319,7 @@ for group in groups:
all_files.append(get_biblio_group_orcid(group))
for author in groups[group]:
all_files.append(get_biblio_orcid(author,groups[group][author]))
all_files.append(get_biblio_structure("geo", 1041793))
all_files.append(get_biblio_structure("comhet", 545341))
all_files.append(get_biblio_structure("rv", 545342))
......
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