Пример #1
0
def eventMakeObject(event, datechoice):
	event = event.split("\n")
	objArray = []
	eventDict = {}
	for each in event:
		if re.match("(?:DTSTART)(.*?)", each): # Find start time
			dtstart 	= each.replace("DTSTART:", "") # Remove non-relevant info
			startTime 	= dateparser.parseVcsTimeFormat(dtstart) # Parse to datetime
			eventDict['startTime'] 	= startTime
		elif re.match("(?:DTEND)(.*?)", each): # Find end time
			dtend 		= each.replace("DTEND:", "") # Remove non-relevant info
			endTime		= dateparser.parseVcsTimeFormat(dtend) # Parse to datetime
			eventDict['endTime']	= endTime
		elif re.match("(?:SUMMARY)(.*?)", each): # Find the SUMMARY-property
			summary = each.split(":") # Split SUMMARY on each comma
			classProperty = summary[1] # Second part of the summary is the class-property
			classProperty = classProperty.replace(" ", "") # Remove spaces
			classProperty = classProperty.split(",") # Split on comma
			classInsert = []
			for each in classProperty:
				if int(each) in classList():
					classURL = '<a href="' + url_for("class_choice", classchoice=int(each)) + '">' \
					+ each + '</a>'
					classInsert.append(classURL)
				else:
					classInsert.append(each)
			eventDict['class']		= ", ".join(classInsert)
			eventDict['teacher']	= summary[2] # 
			eventDict['subject']	= summary[3] # 
			if len(summary) > 4:
				eventDict['subjectID']	= summary[4]
			else:
				eventDict['subjectID']	= None
			if len(summary) > 5:
				eventDict['comment']	= summary[5]
			else:
				eventDict['comment']	= None
		elif re.match("(?:LOCATION)(.*?)", each): # Find the LOCATION-property
			eventDict['location']	= each.replace("LOCATION;ENCODING=QUOTED-PRINTABLE:", "")
	if eventDict['startTime'].date() == datechoice:
		return eventDict
	else:
		return None
Пример #2
0
"""
Main file of Dashboard, an schedule viewer for ABB Industrigymnasium
developed by Emil Tullstedt as a hobby project.

This project has no affliation with the school to do whatsoever.

(C) 2012-2013 Emil Tullstedt
"""

from flask import Flask, render_template
import os
import scraper
import data

APP = Flask(__name__)
CLASSLIST = sorted(data.classList().keys())


@APP.route('/')
@APP.route('/class/')
def class_list():
    """
    Output: HTML-formatted classlist and main page
    """
    return render_template('classList.html', classList=CLASSLIST)


@APP.route('/class/<int:classchoice>/')
@APP.route('/class/<int:classchoice>/<datechoice>/')
@APP.route('/<int:classchoice>/')
@APP.route('/<int:classchoice>/<datechoice>/')