Skip to content

Commit a53260e

Browse files
Carolyn GalvinCarolyn Galvin
Carolyn Galvin
authored and
Carolyn Galvin
committedJun 10, 2017·
code so far
0 parents  commit a53260e

17 files changed

+341
-0
lines changed
 

‎Actors.csv

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Jane,Poona,1 3 5,2015-11-25 2016-01-01
2+
John,Prince,2 4,2016-02-03 2015-12-25

‎Plan.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Given a range of dates
2+
Given days of the week that we have rehearsal
3+
Given actors availability
4+
Given which actors are in which scenes
5+
6+
Give back a list of what scenes can be rehearsed each day
7+
8+
-1. Create a program that takes a range of dates and days of the week, and returns a list of all the dates that
9+
fall on the given days of the week
10+
-2. Given an actor's availability, list that the actor is available on those dates
11+
-3. Given the scenes that an actor is in, list that the scene can be rehearsed on those dates
12+
4. Expand to a list of actors & availability
13+
5. Expand to a list of scenes
14+
6. Add ability to add an actor
15+
7. Add ability to add a conflict on a day of the week
16+
8. Add ability to add a conflict on a specific date

‎Scenes.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
1a "Storyteller1, Storyteller, Poona,"
2+
2a "Storyteller, Poona, MSA, Penis, Prince"
3+
2b "Poona, Prince"
4+
2c "Poona, Rabbit, Storyteller"
5+
3a "Shrub, Stagehands"
6+
3b "Poona, Prince, Rabbit, Guard"
7+
3c "Shrub, Stagehands"
8+
4a "Jasper, Cunt, Shrub,"
9+
5a "Mr Beer, TV, Telegram, Citizens, Stagehand"
10+
6a "Storyteller, Poona, Guard, Prince, Frog,"
11+
7a "TV, Aide, Poona, Intercom Voice"
12+
7b Penis
13+
7c "TV, Poona, Aide, Reporter"
14+
8a MSA
15+
8b "Storyteller, Poona"
16+
9a "TV, Jasper, Cunt"
17+
10a "Storyteller, Jack, TV, Prince, Aide, Mike, Gabby, Devil"
18+
11a "Jack, God, Gabby"
19+
12a "Poona, TV"
20+
12b "Penis, Poona"
21+
13a "MSA, Poona, Shrub, Frog, Box, Kid, Angel"
22+
14a "Storyteller, Poona, Jasper, Cunt"
23+
15a "Suzy-Suzy, Storyteller, Computer, Cops, Mom"
24+
16a "Jasper, Cunt"
25+
17a "Storyteller, Poona,"
26+
18a "Frog, Poona, Rabbit, Prince, God, Jack"
27+
19a "MSA, Frog, Sparky"
28+
20a "Storyteller, Poona, Somebody"
29+
20b "Penis, Band, Stagehands"
30+
20c "Poona, Shrub, MSA, Rabbit, Prince"
31+
20d Everyone
32+
20e "Jasper, Cunt, Shrub"

‎__pycache__/actor.cpython-34.pyc

1.48 KB
Binary file not shown.

‎__pycache__/dates.cpython-34.pyc

3.7 KB
Binary file not shown.

‎__pycache__/rehearsals.cpython-34.pyc

1.51 KB
Binary file not shown.

‎__pycache__/scene.cpython-34.pyc

938 Bytes
Binary file not shown.

‎actor.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Actor:
2+
# name: string
3+
# role: string
4+
# availability: list of ints (represents days of the week the actor is available)
5+
# special: list of strings in the form "yyyy-mm-dd" (represents special dates the actor is NOT available)
6+
def __init__(self, name, role, availability, special):
7+
self.name = name
8+
self.role = role
9+
self.avail = availability
10+
self.special = special
11+
12+
def __str__(self):
13+
return self.name + ', ' + str(self.role) + ', ' + str(self.avail) + ', ' + str(self.special)
14+
15+
# newAvail: list of ints (represents days of the week to add to the actors availability)
16+
def addAvailability(self, newAvail):
17+
for days in newAvail:
18+
if(not(days in self.avail)):
19+
self.avail.append(days)
20+
21+
# newDel: list of ints (represents days of the week to remove from the actors availability)
22+
def removeAvailability(self, newDel):
23+
for days in newDel:
24+
if(days in self.avail):
25+
self.avail.delete(days)
26+
27+
# newSpec: list of strings in the form "yyyy-mm-dd" (represents date to add to actor's unavailiabity)
28+
def addSpecial(self, newSpec):
29+
for dates in newSpec:
30+
if(not(dates in self.special)):
31+
self.special.append(dates)
32+
33+
# delSpec: list of strings in the form "yyyy-mm-dd" (represents date to remove from actor's unavailability)
34+
def removeSpecial(self, delSpec):
35+
for dates in delSpec:
36+
if(dates in self.special):
37+
self.special.delete(dates)
38+
39+
40+

‎actor.pyc

1.81 KB
Binary file not shown.

‎availability.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import dates
2+
import actor
3+
import rehearsals
4+
import scene
5+
6+
7+
##john = actor.Actor("John","Man Who Can Sell Anything",[1, 3, 5], ["2015-11-16","2015-12-25"])
8+
##
9+
##print(john)
10+
##
11+
##rehearsalDates = dates.listAllDays("2015-11-9","2016-2-5",[1, 3, 4])
12+
##rehearsalSchedule = []
13+
## create rehearsal schedule
14+
##for date in rehearsalDates:
15+
## actorList = []
16+
## newReh = rehearsals.RehearsalDate(date, [], [])
17+
## if(newReh.day in john.avail and newReh.date not in john.special):
18+
## newReh.addActor(john.name)
19+
## for sc in john.role.scenes:
20+
## newReh.addScene(sc)
21+
## rehearsalSchedule.append(newReh)
22+
##
23+
##for sched in rehearsalSchedule:
24+
## print(sched)
25+
26+
##def makeActorList():
27+
## actorList = []
28+
## actorsFile = open("Actors.csv")
29+
## actors = actorsFile.readlines()
30+
## actorsFile.close()
31+
##
32+
## for act in actors:
33+
## fields = act.split(',')
34+
## actorList.append(actor.Actor(fields[0], fields[1], fields[2].split(), fields[3].split()))
35+
## return actorList
36+
##
37+
##def makeSceneList():
38+
## sceneList = []
39+
## sceneFile = open("Scenes.txt")
40+
## scenes = sceneFile.readlines()
41+
## sceneFile.close()
42+
##
43+
## for sc in scenes:
44+
## fields = sc.split('\t')
45+
## chars = fields[1].split(', ')
46+
## for i in range(0,len(chars)):
47+
## chars[i] = chars[i].strip('"\n')
48+
## sceneList.append(scene.Scene(fields[0], chars))
49+
## return sceneList
50+
##
51+
##actorsList = makeActorList()
52+
##scenesList = makeSceneList()
53+
54+
days = dates.listAllDays("2016-09-04","2016-11-12",[0,2,4])
55+
weekdays = {0:"Sun",
56+
2:"T",
57+
4:"Th" }
58+
csvstring = ""
59+
for i in range(0,len(days)):
60+
csvstring+=weekdays[dates.dayOfWeek(days[i])] + " " + days[i][5:] + ","
61+
csvfile = open("days.csv", 'w')
62+
csvfile.write(csvstring)
63+
csvfile.close()
64+
print(csvstring)
65+
66+
67+

‎dates.py

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
weekdays = {0: "Sunday",
2+
1: "Monday",
3+
2: "Tuesday",
4+
3: "Wednesday",
5+
4: "Thursday",
6+
5: "Friday",
7+
6: "Saturday" }
8+
9+
# determines the day of the week a particular date falls on, based on the fact that 2015-10-28 is a Wednesday
10+
# date must be string in the form yyyy-mm-dd
11+
def dayOfWeek(date):
12+
13+
year = int(date.split('-')[0])
14+
month = int(date.split('-')[1])
15+
day = int(date.split('-')[2])
16+
17+
monthsReg = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
18+
monthsLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
19+
20+
iterYear = 2015
21+
iterMonth = 10
22+
iterDay = 28
23+
24+
tot = 0
25+
26+
while(True):
27+
if(leapYear(iterYear)):
28+
months = monthsLeap
29+
else:
30+
months = monthsReg
31+
32+
while(iterMonth < 13):
33+
while(iterDay < months[iterMonth-1]+1):
34+
if(iterYear == year and iterMonth == month and iterDay == day):
35+
return (tot+3) % 7
36+
iterDay += 1
37+
tot += 1
38+
iterDay = 1
39+
iterMonth += 1
40+
iterMonth = 1
41+
iterYear += 1
42+
43+
# determines whether a year is a leap year
44+
# year: an int
45+
def leapYear(year):
46+
return year % 4 == 0 and (not(year % 100 == 0) or (year % 400 == 0))
47+
48+
# lists all the dates between two specified dates, inclusive
49+
# start and end must be strings in the form yyyy-mm-dd
50+
def listAllDates(start, end):
51+
52+
retList = []
53+
54+
days = {0:[], 1:[], 2:[], 3:[], 4:[], 5:[], 6:[]}
55+
56+
monthsReg = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
57+
monthsLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
58+
59+
startYear = int(start.split('-')[0])
60+
startMonth = int(start.split('-')[1])
61+
startDay = int(start.split('-')[2])
62+
63+
endYear = int(end.split('-')[0])
64+
endMonth = int(end.split('-')[1])
65+
endDay = int(end.split('-')[2])
66+
67+
leapStart = startYear % 4 == 0 and (not(startYear % 100 == 0) or (startYear % 400 == 0))
68+
leadEnd = endYear % 4 == 0 and (not(endYear % 100 == 0) or (endYear % 400 == 0))
69+
70+
iterYear = startYear
71+
iterMonth = startMonth
72+
iterDay = startDay
73+
74+
while(True):
75+
if(leapYear(iterYear)):
76+
months = monthsLeap
77+
else:
78+
months = monthsReg
79+
80+
while(iterMonth < 13):
81+
while(iterDay < months[iterMonth-1]+1):
82+
retList.append(str(iterYear) + '-' + str(iterMonth) + '-' + str(iterDay))
83+
if(iterYear == endYear and iterMonth == endMonth and iterDay == endDay):
84+
return retList
85+
iterDay += 1
86+
iterDay = 1
87+
iterMonth += 1
88+
iterMonth = 1
89+
iterYear += 1
90+
91+
# lists all the dates in a particular range that fall on particular days of the week
92+
# start & end: strings in the form "yyyy-mm-dd"
93+
# day: a list of ints corresponding to the day (starting with 0 for Sunday)
94+
# returns: goodDates, a list of dictionaries in the form {date:dayofweek}, where date is a string in the form "yyyy-mm-dd"
95+
# and dayofweek is an int 0-6 representing the day of the week (0 is Sunday)
96+
def listAllDays(start, end, day):
97+
dates = listAllDates(start, end)
98+
goodDates = []
99+
for i in dates:
100+
weekday = dayOfWeek(i)
101+
if(weekday in day):
102+
goodDates.append(i)
103+
return goodDates
104+
105+
class RehearsalDate:
106+
# date: string in the form "yyyy-mm-dd"
107+
# actorList: a list of strings that are actor names
108+
# sceneList: a list of strings that are scenes
109+
def __init__(self, date, actorList, sceneList):
110+
self.date = date
111+
self.day = dayOfWeek(date)
112+
self.actorList = actorList
113+
self.sceneList = sceneList
114+
115+
def __str__(self):
116+
return "Date: " + self.date + "\nDay: " + weekdays[self.day] + "\nActors Available: " + str(self.actorList) + "\nScenes: " + str(self.sceneList) + "\n"
117+
118+
def addActor(self, actor):
119+
self.actorList.append(actor)
120+
121+
def addScene(self, scene):
122+
self.sceneList.append(scene)
123+
124+
def removeActor(self, actor):
125+
for act in self.actorList:
126+
if act == actor:
127+
self.actorList.delete(act)
128+
129+
def removeScene(self, scene):
130+
for scenes in self.sceneList:
131+
if scenes == scene:
132+
self.sceneList.delete(scenes)
133+
134+
135+
136+
137+

‎dates.pyc

4.34 KB
Binary file not shown.

‎days.csv

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sun 9-4,T 9-6,Th 9-8,Sun 9-11,T 9-13,Th 9-15,Sun 9-18,T 9-20,Th 9-22,Sun 9-25,T 9-27,Th 9-29,Sun 10-2,T 10-4,Th 10-6,Sun 10-9,T 10-11,Th 10-13,Sun 10-16,T 10-18,Th 10-20,Sun 10-23,T 10-25,Th 10-27,Sun 10-30,T 11-1,Th 11-3,Sun 11-6,T 11-8,Th 11-10,

‎rehearsals.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import dates
2+
3+
class RehearsalDate:
4+
# date: string in the form "yyyy-mm-dd"
5+
# actorList: a list of strings that are actor names
6+
# sceneList: a list of strings that are scenes
7+
def __init__(self, date, actorList, sceneList):
8+
self.date = date
9+
self.day = dates.dayOfWeek(date)
10+
self.actorList = actorList
11+
self.sceneList = sceneList
12+
13+
def __str__(self):
14+
return "Date: " + self.date + "\nDay: " + dates.weekdays[self.day] + "\nActors Available: " + str(self.actorList) + "\nScenes: " + str(self.sceneList)
15+
16+
def addActor(self, actor):
17+
self.actorList.append(actor)
18+
19+
def addScene(self, scene):
20+
self.sceneList.append(scene)
21+
22+
def removeActor(self, actor):
23+
for act in self.actorList:
24+
if act == actor:
25+
self.actorList.delete(act)
26+
27+
def removeScene(self, scene):
28+
for scenes in self.sceneList:
29+
if scenes == scene:
30+
self.sceneList.delete(scenes)

‎rehearsals.pyc

1.85 KB
Binary file not shown.

‎scene.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Scene:
2+
# number: string
3+
# characters: list of strings, representing character names
4+
def __init__(self, number, characters):
5+
self.number = number
6+
self.characters = characters
7+
8+
def __str__(self):
9+
return self.number + ", " + str(self.characters)
10+
11+
def addCharacter(self, char):
12+
self.characters.append(char)
13+
14+
def removeCharacter(self, char):
15+
if(char in self.characters):
16+
self.characters.remove(char)

‎scene.pyc

1.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.