-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter_delfly.py
85 lines (61 loc) · 2.27 KB
/
filter_delfly.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import bibtexparser
import json
from collections import OrderedDict
papers = dict()
mavlabpapers = {}
parser = bibtexparser.bparser.BibTexParser(common_strings=True)
parser.ignore_nonstandard_types = False
with open('./website/all.bib', encoding="utf8") as bibtex_file:
bibtex_str = bibtex_file.read()
bib_database = bibtexparser.loads(bibtex_str, parser=parser)
delfly_database = bibtexparser.bibdatabase.BibDatabase()
rest = bibtexparser.bibdatabase.BibDatabase()
print('================================================================')
for b in bib_database.entries:
#print(b)
if not ('author' in b) or not ('title' in b):
print('ERROR!', b)
print('------------------------------------------------------------------------')
continue
# Paper
title = b['title']
authors = b['author']
delflypaper = False
if 'keywords' in b:
title = title + ' ' + b['keywords']
if 'delfly' in title.lower():
delflypaper = True
if 'flapping' in title.lower():
if not ('flapping dynamics' in title.lower()):
delflypaper = True
if 'flapper' in title.lower():
delflypaper = True
if 'fling' in title.lower():
delflypaper = True
if 'karasek' in authors.lower():
delflypaper = True
if delflypaper:
if ('url' in b) and (not ('pdf' in b)):
b['pdf'] = b['url']
#if 'abstract' in b:
# b.pop('abstract')
delfly_database.entries.append(b)
else:
rest.entries.append(b)
print(mavlabpapers)
# dump back
writer = bibtexparser.bwriter.BibTexWriter()
writer.indent = '\t' # indent entries with 4 spaces instead of one
writer.order_entries_by = 'year'
writer.align_values = True
with open('website/delfly.bib', 'w', encoding='utf8') as bibfile:
bibfile.write('# AUTOGENERATED\n# \n\n')
bibfile.write(writer.write(delfly_database).replace('&',r'\&'))
writer = bibtexparser.bwriter.BibTexWriter()
writer.indent = '\t' # indent entries with 4 spaces instead of one
writer.order_entries_by = 'year'
writer.align_values = True
with open('website/not_delfly.bib', 'w', encoding='utf8') as bibfile:
bibfile.write('# AUTOGENERATED\n# \n\n')
bibfile.write(writer.write(rest).replace('&',r'\&'))
print('Done')