-
Notifications
You must be signed in to change notification settings - Fork 24
/
attendance.py
144 lines (123 loc) · 4.1 KB
/
attendance.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import sys
import urllib2
from BeautifulSoup import BeautifulSoup
# List of the default months the HFOSS course runs
# months = ["09", "10", "11", "12"]
months = ["02", "03", "04", "05"]
# Scrape the whole page
page = urllib2.urlopen("http://linkybook.com/meetbot/rit-foss/2015/")
bigSoup = BeautifulSoup(page)
# Find all of the links
links = bigSoup.findAll('a')
html = []
# Add only the links that end in .html to a list
for link in links:
type1 = link.getText().split('.')[-1]
type2 = link.getText().split('.')[-2]
# Filters out *.log.html links
if "html" in type1 and "log" not in type2:
# Gather date information about the log
date = link.getText().split('.')[1]
year = date.split('-')[0]
month = date.split('-')[1]
day = date.split('-')[2]
# No user input
if len(sys.argv) == 1:
html.append(link)
# Check user input for a specific year
if len(sys.argv) == 2:
if sys.argv[1] in year:
html.append(link)
# Check user input for a specific year and month
elif len(sys.argv) == 3:
if sys.argv[1] in year:
if sys.argv[2] in month:
html.append(link)
# Check user input for a specific year, month, and day
elif len(sys.argv) == 4:
if sys.argv[1] in year:
if sys.argv[2] in month:
if sys.argv[3] in day:
html.append(link)
# Scrape each link for the attendance
for link in html:
page = urllib2.urlopen("http://linkybook.com/meetbot/rit-foss/" +
str(link.getText().split('.')[1].split('-')[0]) +
"/" + str(link.getText()))
smallSoup = BeautifulSoup(page)
# Find all the people who attended the meeting (class)
people = smallSoup.findAll('h3')[-1].findAllNext('li')
present = []
# Populate a list of people who were present during rollcall
for name in people:
present.append(name.getText().split()[0].lower())
# List of students in the class
# classDict = {
# "AgitatedBadger": [],
# "Akaleth": ["Akaleth|Class"],
# "ArcticSphinx": [],
# "Fangy": [],
# "BeruBeruFunBot": [],
# "ChrisKnepper": [],
# "Consuuume": [],
# "Destroyer675000": [],
# "dudeman514": ["Dudeman514"],
# "ExplosiveHippo": [],
# "Grub0": [],
# "LinkSlayer64": ["XLS64|Lappy", "LS64"],
# "Nolski": [],
# "Obliv": ["Obliv|class"],
# "Spectralshadow": ["Spectralshadow5"],
# "TheOnlyTaters": [],
# "Waterseas": [],
# "Xethik": ["XethikClass"],
# "edwfoss": [],
# "emmix": [],
# "gecko_": [],
# "h2g2guy": [],
# "valeatory": [],
# "zanarama": ["zanarama1"]
# }
# List of students in the class
classDict = {
"Kocsen": [],
"c_coffie": [],
"jeid64": [],
"Fortnight": [],
"Pharas": [],
"qwertos": [],
"ChrisKnepper": [],
"amm4108": [],
"ajman1101": [],
"loothelion": [],
"dropofwill": [],
"snapschott": [],
"msoucy": [],
"Kaffys": [],
"h2g2guy": [],
"mtubinis": [],
"beWhitty": [],
"wywin": [],
"BeruBeruFunBot": [],
}
date = link.getText().split('.')[1]
year = date.split('-')[0]
month = date.split('-')[1]
day = date.split('-')[2]
# Display the date
print("\n###### Attendance for {0}-{1}-{2} ######".format(
year, month, day))
# Print out each student's status that day
for student in classDict.keys():
if student.lower() in present:
print("%s was present!" % student)
else:
has_alias = False
for alias in classDict[student]:
if alias.lower() in present:
has_alias = True
break
if has_alias:
print ("%s was present!" % student)
else:
print("%s was not in class." % student)