-
Notifications
You must be signed in to change notification settings - Fork 3
/
twXiv.py
executable file
·81 lines (71 loc) · 2.21 KB
/
twXiv.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
#!/usr/bin/env python3
# written by So Okada so.okada@gmail.com
# a main interface of twXiv
# https://github.com/so-okada/twXiv/
import json
import argparse
import traceback
from variables import *
import twXiv_post as tXp
parser = argparse.ArgumentParser(
description='arXiv daily new submissions by tweets, '
'abstracts by replies, '
'cross-lists by retweets, '
'and replacements by quotes and retweets.')
parser.add_argument("--switches_keys",
"-s",
required=True,
default='',
help="output switches and api keys in json")
parser.add_argument("--logfiles",
"-l",
default='',
help="log file names in json")
parser.add_argument("--aliases",
"-a",
default='',
help="aliases of arXiv categories in json")
parser.add_argument("--captions",
"-c",
default='',
help="captions of arXiv categories in json")
parser.add_argument("--mode",
"-m",
choices=[0, 1],
type=int,
default='0',
help='1 for twitter and 0 for stdout only')
args = parser.parse_args()
switches = args.switches_keys
logfiles = args.logfiles
aliases = args.aliases
captions = args.captions
pt_mode = args.mode
try:
f = open(switches)
except Exception:
traceback.print_exc()
raise Exception('can not obtain output switches and api keys')
switches = json.load(f)
if logfiles:
try:
f = open(logfiles)
except Exception:
traceback.print_exc()
raise Exception('can not obtain log filenames')
logfiles = json.load(f)
if aliases:
try:
f = open(aliases)
except Exception:
traceback.print_exc()
raise Exception('can not obtain aliases of arXiv categories')
aliases = json.load(f)
if captions:
try:
f = open(captions)
except Exception:
traceback.print_exc()
raise Exception('can not obtain captions of arXiv categories')
captions = json.load(f)
tXp.main(switches, logfiles, captions, aliases, pt_mode)