Skip to content

Commit d03d15b

Browse files
author
Remy DeCausemaker
committed
Added atendance.py script
1 parent d833ead commit d03d15b

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

attendance.py

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import sys
2+
import urllib2
3+
from BeautifulSoup import BeautifulSoup
4+
5+
# List of the default months the HFOSS course runs
6+
# months = ["09", "10", "11", "12"]
7+
months = ["02", "03", "04", "05"]
8+
9+
# Scrape the whole page
10+
page = urllib2.urlopen("http://linkybook.com/meetbot/rit-foss/2015/")
11+
12+
bigSoup = BeautifulSoup(page)
13+
14+
# Find all of the links
15+
links = bigSoup.findAll('a')
16+
html = []
17+
18+
# Add only the links that end in .html to a list
19+
for link in links:
20+
21+
type1 = link.getText().split('.')[-1]
22+
type2 = link.getText().split('.')[-2]
23+
24+
# Filters out *.log.html links
25+
if "html" in type1 and "log" not in type2:
26+
27+
# Gather date information about the log
28+
date = link.getText().split('.')[1]
29+
year = date.split('-')[0]
30+
month = date.split('-')[1]
31+
day = date.split('-')[2]
32+
33+
# No user input
34+
if len(sys.argv) == 1:
35+
html.append(link)
36+
37+
# Check user input for a specific year
38+
if len(sys.argv) == 2:
39+
if sys.argv[1] in year:
40+
html.append(link)
41+
42+
# Check user input for a specific year and month
43+
elif len(sys.argv) == 3:
44+
if sys.argv[1] in year:
45+
if sys.argv[2] in month:
46+
html.append(link)
47+
48+
# Check user input for a specific year, month, and day
49+
elif len(sys.argv) == 4:
50+
if sys.argv[1] in year:
51+
if sys.argv[2] in month:
52+
if sys.argv[3] in day:
53+
html.append(link)
54+
55+
# Scrape each link for the attendance
56+
for link in html:
57+
page = urllib2.urlopen("http://linkybook.com/meetbot/rit-foss/" +
58+
str(link.getText().split('.')[1].split('-')[0]) +
59+
"/" + str(link.getText()))
60+
smallSoup = BeautifulSoup(page)
61+
62+
# Find all the people who attended the meeting (class)
63+
people = smallSoup.findAll('h3')[-1].findAllNext('li')
64+
present = []
65+
66+
# Populate a list of people who were present during rollcall
67+
for name in people:
68+
present.append(name.getText().split()[0].lower())
69+
70+
# List of students in the class
71+
# classDict = {
72+
# "AgitatedBadger": [],
73+
# "Akaleth": ["Akaleth|Class"],
74+
# "ArcticSphinx": [],
75+
# "Fangy": [],
76+
# "BeruBeruFunBot": [],
77+
# "ChrisKnepper": [],
78+
# "Consuuume": [],
79+
# "Destroyer675000": [],
80+
# "dudeman514": ["Dudeman514"],
81+
# "ExplosiveHippo": [],
82+
# "Grub0": [],
83+
# "LinkSlayer64": ["XLS64|Lappy", "LS64"],
84+
# "Nolski": [],
85+
# "Obliv": ["Obliv|class"],
86+
# "Spectralshadow": ["Spectralshadow5"],
87+
# "TheOnlyTaters": [],
88+
# "Waterseas": [],
89+
# "Xethik": ["XethikClass"],
90+
# "edwfoss": [],
91+
# "emmix": [],
92+
# "gecko_": [],
93+
# "h2g2guy": [],
94+
# "valeatory": [],
95+
# "zanarama": ["zanarama1"]
96+
# }
97+
98+
# List of students in the class
99+
classDict = {
100+
"Kocsen": [],
101+
"c_coffie": [],
102+
"jeid64": [],
103+
"Fortnight": [],
104+
"Pharas": [],
105+
"qwertos": [],
106+
"ChrisKnepper": [],
107+
"amm4108": [],
108+
"ajman1101": [],
109+
"loothelion": [],
110+
"dropofwill": [],
111+
"snapschott": [],
112+
"msoucy": [],
113+
"Kaffys": [],
114+
"h2g2guy": [],
115+
"mtubinis": [],
116+
"beWhitty": [],
117+
"wywin": [],
118+
"BeruBeruFunBot": [],
119+
}
120+
121+
date = link.getText().split('.')[1]
122+
year = date.split('-')[0]
123+
month = date.split('-')[1]
124+
day = date.split('-')[2]
125+
126+
# Display the date
127+
print("\n###### Attendance for {0}-{1}-{2} ######".format(
128+
year, month, day))
129+
130+
# Print out each student's status that day
131+
for student in classDict.keys():
132+
if student.lower() in present:
133+
print("%s was present!" % student)
134+
else:
135+
has_alias = False
136+
for alias in classDict[student]:
137+
if alias.lower() in present:
138+
has_alias = True
139+
break
140+
141+
if has_alias:
142+
print ("%s was present!" % student)
143+
else:
144+
print("%s was not in class." % student)

0 commit comments

Comments
 (0)