Quick start¶
- Follow these instructions, to allow access to the Google Calendar API. (Make sure to keep track of the client_secret.json file)
- Fork this repository
- Clone your fork to your development machine
- Navigate to the repository folder in your terminal
- Install dependencies (preferably in a virtual environment) pip install -r requirements.txt
- Link the CLIENT_SECRET (get_events.py module) object to the client_secret.json file you dowloaded.
- Generate credentials by running _get_credentials() function in get_events.py module. This can be accomplished by calling the module directly by running python get_events from the command line. Be sure ~/.credentials does not exist when running the function and that CLIENT_SECRET is properly referenced.
Code Sample¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import get_events as ge
import dfsort as dfs
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
CLIENT_SECRET_FILE = 'client_secret.json'
credentials = ge.get_credentials()
service = ge.create_svs_obj(credentials)
evStart_evEnd = ge.event_range('week')
evStartEvEnd_eventsDct = ge.get_events(service, evStart_evEnd,
["calendar_name_1",
"calendar_name_2",
"etc."])
evStartEvEnd_calEvDfsDct = dfs.add_durations(evStartEvEnd_eventsDct)
(evStart_evEnd, calEvDfsDct) = evStartEvEnd_calEvDfsDct
calendar = 'Production'
workTypesDct = dfs.get_unique_events(evStartEvEnd_calEvDfsDct, calendar)
workType = 'Contract Work'
projectNm = 'Project Name'
workTypesDf = workTypesDct[workType]
projectDf = dfs.get_projects(workTypesDf, projectNm)
projectDf.to_csv(projectNm+'.csv')
|