-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler.py
73 lines (58 loc) · 2.17 KB
/
scheduler.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
64
65
66
67
68
69
70
71
72
73
from bs4 import BeautifulSoup
import argparse
parser = argparse.ArgumentParser(description='Stay organised. Stay nerdy. Prettily.', epilog='Created by darrenjr')
parser.add_argument('-f', '--font', metavar='', help='Type of text font', default='sans-serif')
parser.add_argument('-b', '--background', metavar='', help='Colour of background', default='#666666')
parser.add_argument('-t', '--table', metavar='', help='Colour of headers and table cells', default='#009879')
args = parser.parse_args()
# opening the downloaded SA_LEARNER_SERVICES.SSR_SSENRL_SCHD_W.html
with open('SA_LEARNER_SERVICES.SSR_SSENRL_SCHD_W.html') as frame:
soup = BeautifulSoup(frame, 'html.parser')
table = soup.find('table', 'PSLEVEL1GRIDWBO')
table.find(class_='PSLEVEL1GRIDLABEL').parent.replace_with('')
def customise_css():
# changing background colour
table['style'] = f'background-color: {args.background};'
# changing table colour
for i in table.find_all('td', style='color:rgb(0,0,0);background-color:rgb(182,209,146);text-align: center;'):
i.span['class'], i.span['style'] = 'MAINREASON', f'background-color: {args.table}; font-family: {args.font};'
i['class'], i['style'] = 'MAINREASON_BG', f'background-color: {args.table};'
for i in table.find_all('th'):
i['style'] = f'background-color: {args.table}; font-family: {args.font};'
# removing days of the week
i.string = i.contents[0]
customise_css()
html_header = '''<head><style>
.PSLEVEL1GRIDWBO {
border-collapse: collapse;
font-size: 0.9em;
margin: 0 auto;
transform: rotate(90deg);
transform-origin:bottom left;
position:absolute;
top: -100vw;
left: 0;
height:100vw;
width:100vh;
overflow:auto;
}
.PSLEVEL1GRIDWBO tbody tr th, .MAINREASON {
color: #ffffff;
text-align: center;
}
.PSLEVEL1GRIDWBO tbody tr td {
text-align: center;
border: 1px solid #dddddd;
}
.MAINREASON {
font-size: 0.9em;
font-family: sans-serif;
}
.MAINREASON_BG {
padding-top: 20px;
padding-bottom: 20px;
}
</style></head>
'''
with open('your_very_own_schedule.html', 'w') as new_file:
new_file.write(html_header + str(table))