-
Notifications
You must be signed in to change notification settings - Fork 13
/
makebib.py
executable file
·32 lines (28 loc) · 1.11 KB
/
makebib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
import yaml
import os
#get .bib for files with arXiv identifier
with open(r'_data/publist.yml') as file:
pubs = yaml.load(file, Loader=yaml.FullLoader)
for pub in pubs:
for k,v in pub.items():
if (k=='url'):
url=v
if (k=='arxiv'):
print('working on ArXiv file ' + url)
os.system("./scripts/arxiv2bib.py " + str(v) + " > papers/" + url +".txt")
#get .bib for files with DOI
with open(r'_data/publist.yml') as file:
pubs = yaml.load(file, Loader=yaml.FullLoader)
for pub in pubs:
for k,v in pub.items():
if (k=='url'):
url=v
if (k=='doi'):
print('working on DOI file ' + url)
os.system("./scripts/doi2bib.py " + str(v) + " > papers/" + url +".txt")
#remove empty lines that doi2bib gives
open("papers/tmp.bib",'w').write(
''.join(
l for l in open("papers/" + url + ".txt") if l.strip()))
os.system("mv papers/tmp.bib papers/" + url + ".txt")