Browse Source

basically done need glue code

partial
Raphael Roberts 7 years ago
parent
commit
1f0e3bad58
  1. 3
      .gitignore
  2. 26
      body_create.py

3
.gitignore

@ -1,3 +1,4 @@
*.pkl
*.json
__pycache__
/api_info
/api_info

26
body_create.py

@ -1,6 +1,9 @@
from dateutil import rrule
from gcalendar import dateTime
import datetime
import pickle
import json
LOCATION = "5500 St Louis Ave, Chicago, IL 60625"
# event = {
# 'summary': 'Google I/O 2015',
# 'location': '800 Howard St., San Francisco, CA 94103',
@ -34,13 +37,22 @@ def rrule_former(class_obj):
start =datetime.datetime.combine(class_obj.date_range[0],class_obj.time_range[0]).astimezone()
end =datetime.datetime.combine(class_obj.date_range[1],class_obj.time_range[1]).astimezone()
days = list(map(lambda day: (day -1) % 7,days))
days = [ (day -1) % 7 for day in days]
ret = rrule.rrule(freq=rrule.WEEKLY,dtstart=start,wkst=rrule.SU,until=end,byweekday=days)
return ret
def create_body(_class):
if _class.time_range:
body = {}
body['recurrence'] = [str(rrule_former(_class))]
body['start'] = dateTime(datetime.datetime.combine(_class.date_range[0],_class.time_range[0]))
body['end'] = dateTime(datetime.datetime.combine(_class.date_range[1],_class.time_range[0]))
body['summary'] = _class.title
body['description'] = 'location: {}'.format(_class.location)
body['location'] = LOCATION
return body
def test():
def test_rrule():
#test
now = datetime.datetime.now()
from munch import Munch
@ -56,4 +68,10 @@ def test():
],
)
test_result = rrule_former(test_obj)
return locals()
return locals()
def test_class2body():
with open('classes.pkl','rb') as file:
classes = pickle.load(file)
test_result = list(map(create_body,classes))
return test_result
Loading…
Cancel
Save