-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdataanalyzer.py
More file actions
71 lines (52 loc) · 2.46 KB
/
dataanalyzer.py
File metadata and controls
71 lines (52 loc) · 2.46 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
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Provides information about archive
Examples:
- What was said about Musk
$ --search "title=*Musk*"
- What was said about Musk (title, link, description, etc)
$ --search "Musk"
TODO
- Output formats? (md)?
- Maybe it could produce a chart?
"""
import argparse
import time
import os
import json
from sqlalchemy import create_engine
from linkarchivetools import DbAnalyzer
class Parser(object):
def parse(self):
self.parser = argparse.ArgumentParser(description="Data analyzer program")
self.parser.add_argument("--db", help="DB to be scanned")
self.parser.add_argument("--search", help="Search, with syntax same as the main program / site.")
self.parser.add_argument("--order-by", default="page_rating_votes", help="order by column.")
self.parser.add_argument("--asc", action="store_true", help="order ascending")
self.parser.add_argument("--desc", action="store_true", help="order descending")
self.parser.add_argument("--table", default="linkdatamodel", help="Table name")
self.parser.add_argument("--title", action="store_true", help="displays title")
self.parser.add_argument("--description", action="store_true", help="displays description")
self.parser.add_argument("--status", action="store_true", help="displays status")
self.parser.add_argument("--tags", action="store_true", help="displays tags")
self.parser.add_argument("--social", action="store_true", help="displays social data")
self.parser.add_argument("--date-published", action="store_true", help="displays date-published")
self.parser.add_argument("--source", action="store_true", help="displays source")
self.parser.add_argument("--summary", action="store_true", help="displays summary of tables")
self.parser.add_argument("--columns", action="store_true", help="displays summary of tables column nmaes")
self.parser.add_argument("-i", "--ignore-case", action="store_true", help="Ignores case")
self.parser.add_argument("-v", "--verbosity", type=int, default=1, help="Verbosity level")
self.args = self.parser.parse_args()
return True
def main():
p = Parser()
if not p.parse():
print("Could not parse options")
return
args = p.args
analyzer = DbAnalyzer(input_db = p.args.db, args=p.args)
if p.args.summary:
analyzer.print_summary()
else:
analyzer.search()
if __name__ == "__main__":
main()