forked from isLinXu/paper-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_paper.py
94 lines (81 loc) · 3.48 KB
/
get_paper.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
86
87
88
89
90
91
92
93
94
import logging
import argparse
import sys
from utils.configs import load_config
from utils.get_infos import get_daily_papers
from utils.json_tools import json_to_md
from utils.updates import update_paper_links, update_json_file
sys.path.insert(0, '/utils/')
logging.basicConfig(format='[%(asctime)s %(levelname)s] %(message)s',
datefmt='%m/%d/%Y %H:%M:%S',
level=logging.INFO)
base_url = "https://arxiv.paperswithcode.com/api/v0/papers/"
github_url = "https://api.github.com/search/repositories"
arxiv_url = "http://arxiv.org/"
def run(**config):
# TODO: use config
data_collector = []
data_collector_web = []
keywords = config['kv']
max_results = config['max_results']
publish_readme = config['publish_readme']
publish_gitpage = config['publish_gitpage']
publish_wechat = config['publish_wechat']
show_badge = config['show_badge']
b_update = config['update_paper_links']
logging.info(f'Update Paper Link = {b_update}')
if config['update_paper_links'] == False:
logging.info(f"GET daily papers begin")
for topic, keyword in keywords.items():
logging.info(f"Keyword: {topic}")
data, data_web = get_daily_papers(topic, query=keyword,max_results=max_results,
start_date=config['start_date'], end_date=config['end_date'])
data_collector.append(data)
data_collector_web.append(data_web)
print("\n")
logging.info(f"GET daily papers end")
# 1. update README.md file
if publish_readme:
json_file = config['json_readme_path']
md_file = config['md_readme_path']
# update paper links
if config['update_paper_links']:
update_paper_links(json_file)
else:
# update json data
update_json_file(json_file, data_collector)
# json data to markdown
json_to_md(json_file, md_file, task='Update Readme',
show_badge=show_badge)
# 2. update docs/index.md file (to gitpage)
if publish_gitpage:
json_file = config['json_gitpage_path']
md_file = config['md_gitpage_path']
# TODO: duplicated update paper links!!!
if config['update_paper_links']:
update_paper_links(json_file)
else:
update_json_file(json_file, data_collector)
json_to_md(json_file, md_file, task='Update GitPage',
to_web=True, show_badge=show_badge,
use_tc=False, use_b2t=False)
# 3. Update docs/wechat.md file
if publish_wechat:
json_file = config['json_wechat_path']
md_file = config['md_wechat_path']
# TODO: duplicated update paper links!!!
if config['update_paper_links']:
update_paper_links(json_file)
else:
update_json_file(json_file, data_collector_web)
json_to_md(json_file, md_file, task='Update Wechat', to_web=False, use_title=False, show_badge=show_badge)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--config_path', type=str, default='config.yaml',
help='configuration file path')
parser.add_argument('--update_paper_links', default=False,
action="store_true", help='whether to update paper links etc.')
args = parser.parse_args()
config = load_config(args.config_path)
config = {**config, 'update_paper_links': args.update_paper_links}
run(**config)