-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslack.py
More file actions
59 lines (37 loc) · 1.12 KB
/
slack.py
File metadata and controls
59 lines (37 loc) · 1.12 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------
# (c) kelu124
# cc-by-sa/4.0/
# -------------------------
from bs4 import BeautifulSoup
import re
import os
import urllib2
import datetime
import html2text
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def GetFiles(folder,extension):
Messages = []
for root, directories, filenames in os.walk('./'):
for filename in filenames:
#print os.path.join(root,filename)
if (extension in filename) and (folder+"-data" in root) and ("the_trove-raw" not in root) and ("Readme" not in filename):
Messages.append(os.path.join(root,filename) )
return Messages
LotsOfLogs = GetFiles("slack",".log")
for item in LotsOfLogs:
with open(item) as f:
print item
content = ""
for line in f:
TmpLine = line.split(">")
value = int(TmpLine[0].split(".")[0]) #
TmpLine[0] = "* _"+str(datetime.datetime.fromtimestamp(int(value)).strftime('%Y-%m-%d %H:%M:%S'))+"_"
lineBack = ">".join(TmpLine)
content += lineBack
file = open("slack-data/"+item.split("/")[-1].split(".")[0]+".md", 'w')
file.write(content)
file.close()