-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
53 lines (40 loc) · 1.25 KB
/
main.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
import argparse
import json
from datetime import datetime
from collect import CollectData
from publish import Publisher
def dump_html(h):
html = """
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/styles.css" media="all">
</head>
<body>
<div class=".wiki-content">
{htmlcontent}
</body>
</html>
""".format(htmlcontent=h)
with open('test.html', 'w') as file:
file.write(html)
class Config:
def __init__(self, username, password):
self.username = username
self.password = password
with open('config.json', 'r') as f:
self.content = json.load(f)
if __name__ == '__main__':
cmdline_parser = argparse.ArgumentParser()
cmdline_parser.add_argument("-v", "--verbose", action="store_true")
cmdline_parser.add_argument("-u", "--user")
cmdline_parser.add_argument("-p", "--password")
cmdline_args = cmdline_parser.parse_args()
config = Config(cmdline_args.user, cmdline_args.password)
c = CollectData(config)
results = c.get_version_info_per_street()
p = Publisher(config)
htmlresult = p.generate_html(results)
if cmdline_args.verbose:
dump_html(htmlresult)
else:
p.publish(htmlresult)