-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_update_publications.py
More file actions
58 lines (44 loc) · 1.57 KB
/
Copy pathauto_update_publications.py
File metadata and controls
58 lines (44 loc) · 1.57 KB
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
import datetime
from pathlib import Path
from ruamel.yaml import YAML
from . import add_publications_by_author
def main(save_dir="_posts/papers", site_data_dir="_data/", use_ignore_list=True):
site_data_dir = Path(site_data_dir)
yaml = YAML()
yaml.preserve_quotes = True
with open(site_data_dir / "authors.yml") as f:
authors = yaml.load(f)
for author in authors.values():
auto_update = author.get("auto_update_publications", False)
author_id = author.get("semantic_scholar_id", False)
if auto_update and author_id:
year = int(datetime.datetime.now().year)
parsed = {
"start": year,
"end": year,
"author_id": author_id,
}
print(f"Updating publications for {author['name']} ({author_id})...")
add_publications_by_author.main(
parsed=parsed, save_dir=save_dir, use_ignore_list=use_ignore_list
)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"--save_dir",
help="The directory to save the new files.",
default="_posts/papers",
)
parser.add_argument(
"--site_data_dir", help="The directory with the site data.", default="_data/"
)
parser.add_argument(
"--use_ignore_list",
help="Whether to use the ignore list.",
default="true",
choices=["true", "false"],
)
args = parser.parse_args()
use_ignore_list = args.use_ignore_list == "true"
main(**vars(args))