-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspiderweb.py
executable file
·63 lines (46 loc) · 1.82 KB
/
inspiderweb.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
#!/usr/bin/env python3
import sys
import configparser
from inspiderweb.log import logcontrol, logger
from inspiderweb.database import Database
from inspiderweb.dotgraph import DotGraph
from inspiderweb.recidextractor import get_recid_from_queries, \
get_recids_from_bibkey_paths, get_recids_from_url_paths, \
get_recids_from_recid_paths
from inspiderweb.cli import cli_parser, get_plot_connections
""" Main file of inspiderweb: Tool to analyze paper reference networks.
Currently hosted at: https://github.com/klieret/inspiderweb
Run this file via `python3 inspiderweb.py --help` for instructions on
usage. """
args = cli_parser.parse_args()
print(args.plot)
logcontrol.set_verbosity_from_argparse(args.verbosity)
# fixme: add tests again
if args.plot and not args.output:
logger.critical("We need output filename to plot. Exiting.")
sys.exit(20)
# todo: maybe use a proper format to save the record data or at least allow ...
# .... to export into such
# todo: add clusters
# todo: extract more infomration; add title as tooltip
# fixme: Restore .travis to specific tests again.
db = Database(args.database[0])
db.load(args.database)
db.statistics()
# get recids
recids = set()
recids.update(get_recid_from_queries(args.queries, db=db))
recids.update(get_recids_from_bibkey_paths(args.bibkeypaths, db=db))
recids.update(get_recids_from_recid_paths(args.recidpaths))
recids.update(get_recids_from_url_paths(args.urlpaths))
db.autocomplete_records(args.get, force=args.forceupdate, recids=recids)
if args.labels:
db.get_labels_from_file(args.labels)
if args.plot:
config = configparser.ConfigParser()
config.read(args.config)
dg = DotGraph(db, config["dotgraph"])
dg.add_connections(get_plot_connections(args.plot, recids, db))
dg.generate_dot_str(rank=args.rank)
dg.write_to_file(args.output)
db.save()