Created
September 1, 2018 12:59
-
-
Save Greenscreener/ab19829c9574f30d135de4c6dd882cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7:05-7:50 | 7:55-8:40 | 8:50-9:35 | 9:55-10:40 | 10:50-11:35 | 11:45-12:30 | 12:35-13:20 | 13:25-14:10 | 14:15-15:00 | 15:05-15:50 | 15:55-16:40 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | |
1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys; | |
import urllib.parse; | |
events = []; | |
urlprefix = "http://llama.location.profiles/Generated+from+timetable/"; | |
inputStr = sys.stdin.read(); | |
inputSplitBynewline = inputStr.split("\n"); | |
inputFull = []; | |
for i in inputSplitBynewline: | |
inputFull.append(i.split(",")); | |
lessonTimes = inputFull[0]; | |
parsedLessonTimes = []; | |
for j in lessonTimes: | |
fromTo = j.split("-"); | |
timeFrom = fromTo[0].split(":"); | |
timeTo = fromTo[1].split(":"); | |
parsedTimeFrom = int(timeFrom[0])*60+int(timeFrom[1]); | |
parsedTimeTo = int(timeTo[0])*60+int(timeTo[1]); | |
parsedLessonTimes.append([parsedTimeFrom,parsedTimeTo]); | |
def parseLessonsForDay(lessonTimes, dayLessons): | |
lessonTimesForDay = []; | |
for k in range(len(dayLessons)): | |
if dayLessons[k] == "1": | |
lessonTimesForDay.append(lessonTimes[k]); | |
return lessonTimesForDay; | |
def generateSilentEventOR(lessonTimesForDay): | |
silentEventOR = "|or|\p"; | |
for l in lessonTimesForDay: | |
silentEventOR+="t\p"+str(l[0])+"\p"+str(l[1])+"\p"; | |
return silentEventOR+"|0|0|"; | |
def generateNormalEventOR(lessonTimesForDay): | |
normalEventOR = "|or|\p"; | |
for m in range(len(lessonTimesForDay)): | |
try: | |
normalEventOR+="t\p"+str(lessonTimesForDay[m][1])+"\p"+str(lessonTimesForDay[m+1][0])+"\p"; | |
except IndexError: | |
normalEventOR+="t\p"+str(lessonTimesForDay[m][1])+"\p"+str(lessonTimesForDay[m][1] + 1)+"\p"; | |
return normalEventOR+"|0|0|"; | |
def generateSilentEventForDay(weekday): | |
if weekday is 4: | |
weekdayName = "Monday"; | |
weekdayNumber = 1; | |
elif weekday is 8: | |
weekdayName = "Tuesday"; | |
weekdayNumber = 2; | |
elif weekday is 16: | |
weekdayName = "Wednesday"; | |
weekdayNumber = 3; | |
elif weekday is 32: | |
weekdayName = "Thursday"; | |
weekdayNumber = 4; | |
elif weekday is 64: | |
weekdayName = "Friday"; | |
weekdayNumber = 5; | |
else: | |
raise InputError("Invalid weekday"); | |
event = weekdayName + " - Lessons|0-1-0-0-0-0-0-0-1-0-Generated from timetable-0-|:|y|" + str(weekday) + "|e|Work" + generateSilentEventOR(parseLessonsForDay(parsedLessonTimes,inputFull[weekdayNumber])) + "vc|1|isPrázdniny|0|p2|Vibrace|0|"; | |
return event; | |
def generateNormalEventForDay(weekday): | |
if weekday is 4: | |
weekdayName = "Monday"; | |
weekdayNumber = 1; | |
elif weekday is 8: | |
weekdayName = "Tuesday"; | |
weekdayNumber = 2; | |
elif weekday is 16: | |
weekdayName = "Wednesday"; | |
weekdayNumber = 3; | |
elif weekday is 32: | |
weekdayName = "Thursday"; | |
weekdayNumber = 4; | |
elif weekday is 64: | |
weekdayName = "Friday"; | |
weekdayNumber = 5; | |
else: | |
raise InputError("Invalid weekday"); | |
event = weekdayName + " - Breaks|0-1-0-0-0-0-0-0-1-0-Generated from timetable-0-|:|y|" + str(weekday) + "|e|Work" + generateNormalEventOR(parseLessonsForDay(parsedLessonTimes,inputFull[weekdayNumber])) + "vc|1|isPrázdniny|0|p2|Zvuk|0|"; | |
return event; | |
for n in [4,8,16,32,64]: | |
urlprefix+=urllib.parse.quote_plus(generateNormalEventForDay(n))+"/"; | |
urlprefix+=urllib.parse.quote_plus(generateSilentEventForDay(n))+"/"; | |
print(urlprefix); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://llama.location.profiles/Subway/Subway|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|2| | |
http://llama.location.profiles/Monday/Monday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|4| | |
http://llama.location.profiles/Tuesday/Tuesday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|8| | |
http://llama.location.profiles/Wednesday/Wednesday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|16| | |
http://llama.location.profiles/Thursday/Thursday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|32| | |
http://llama.location.profiles/Friday/Friday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|64| | |
http://llama.location.profiles/Saturday/Saturday|0-1-0-0-0-0-0-0-1-0-Test-0-|:|y|128| | |
Days of the week | |
- 0 | |
Sunday 0|1 | |
Monday 0|1 | |
Tuesday 0|1 | |
Wednesday 0|1 | |
Thursday 0|1 | |
Friday 0|1 | |
Saturday 0|1 | |
| | |
V | |
|y|INT| | |
In Areas | |
|e|NAME| | |
http://llama.location.profiles/Variable 0/Variable 0|0-1-0-0-0-0-0-0-1-0-Test-0-|:|vc|1|isPrázdniny|0| | |
http://llama.location.profiles/Variable 0/Variable 0|0-1-0-0-0-0-0-0-1-0-Test-0-|:|vc|0|isPrázdniny|0| | |
Variables | |
== - 1, != - 0 -, | |
V | |
|vc|BOOL|NAME|VALUE | |
http://llama.location.profiles/OR/OR|0-1-0-0-0-0-0-0-1-0-Test-0-|:|or|vc\p1\pisPrázdniny\p0\pvc\p1\pisPrázdniny\p0\p|0|0| | |
OR | |
|or|(Normal syntax | is replaced with \p)|0|0| | |
http://llama.location.profiles/Time between/Time between|0-1-0-0-0-0-0-0-1-0-Test-0-|:|t|540|1020| | |
Time between | |
|t|(minutes from midnight)|(minutes from midnight)| | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment