Total Complexity | 6 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import os |
||
2 | class WebWriter: |
||
3 | """ |
||
4 | Handles writing out to teh home folder of the running user. |
||
5 | Creates a very simple web page that just lists all the images posted in a channel the bot's in. |
||
6 | Probably in trouble for cp because of teh 4cdn links. |
||
7 | """ |
||
8 | def __init__(self): |
||
9 | self.path = '~/public_html/img/' |
||
10 | |||
11 | def _generate(self, data): |
||
12 | if data is None: |
||
13 | return |
||
14 | |||
15 | if not os.path.exists(os.path.expanduser(self.path)): |
||
16 | os.makedirs(os.path.expanduser(self.path)) |
||
17 | |||
18 | with open(os.path.expanduser('~/public_html/img/index.html'),'w+') as f: |
||
19 | f.write("<html><body>\n") |
||
20 | f.write("<font size=7>ANYTHING AND EVERYTHING ON THIS PAGE MAY BE NSFW. YOU HAVE BEEN WARNED.</font><br />\n") |
||
21 | for line in data: |
||
22 | f.write(line[2] + " pasted link <a href=\"" + line[1] + "\">" + line[1] + "</a> at "+str(line[3])+" UTC<br>\n") |
||
23 | f.write("</html></body>\n") |
||
24 |