Browse Source

Started on the model side of the project

master
Raphael Roberts 6 years ago
commit
0282558130
  1. 2
      .gitignore
  2. 0
      panera_sync/__init__.py
  3. 16
      panera_sync/constants.py
  4. 35
      panera_sync/models.py
  5. 4
      requirements.txt
  6. 6
      test.py

2
.gitignore

@ -0,0 +1,2 @@
/.dir-locals.el
__pycache__

0
panera_sync/__init__.py

16
panera_sync/constants.py

@ -0,0 +1,16 @@
import datetime
import enum
PANERA_DATE_FORMAT = "%Y-%m-%d"
BASE_URL = "https://pnra.panerabread.com/boh/self_service/schedule/week/{date}"
WEEK = datetime.timedelta(days=7)
class WEEKDAYS(enum.IntEnum):
MO = 0
TU = 1
W = 2
TH = 3
F = 4
S = 5
SU = 6

35
panera_sync/models.py

@ -0,0 +1,35 @@
import datetime
from gapi.apis.calendar_api.models import Event
from .constants import WEEKDAYS, WEEK
class Workday:
def __init__(
self, start_time: datetime.datetime, end_time: datetime.datetime, location
):
self.start_time = start_time
self.end_time = end_time
self.location = location
def convert_to_Event(self) -> Event:
e = Event(self.start_time, self.end_time, location=self.location)
e.add_reminder(60)
return e
class PaneraWeek:
def __init__(self, start_date: datetime.date, work_location):
if start_date.weekday() != WEEKDAYS.W:
raise ValueError(
('"start_date is" on a "{:%A}" instead of Wednesday'.format(start_date))
)
self.start_date = start_date
self.workdays = []
def get_week_end(self):
return self.start_date + datetime.timedelta(days=7 - 1)
def add_workday(self, workday: Workday):
self.workdays.append(workday)

4
requirements.txt

@ -0,0 +1,4 @@
websockets==6.0
rlbr-browser
simple-gapi
lxml

6
test.py

@ -0,0 +1,6 @@
import datetime
from panera_sync.constants import WEEKDAYS
from panera_sync.models import PaneraWeek
if __name__ == "__main__":
P = PaneraWeek(datetime.date(2020, 1, 22))