Skip to content

Commit

Permalink
Merge pull request #23 from elliot-100/pep8_functions
Browse files Browse the repository at this point in the history
Make function names PEP-8 compliant
  • Loading branch information
Olen authored Oct 5, 2022
2 parents 7441cf2 + 9271f4a commit 7e9ea11
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ password = 'Pa55worD'
async def main():
s = spond.Spond(username=username, password=password)
groups = await s.getGroups()
groups = await s.get_groups()
for group in groups:
print(group['name'])
await s.clientsession.close()
Expand All @@ -37,21 +37,21 @@ loop.run_until_complete(main())

## Functions

### getGroups()
### get_groups()
Gets all your group memberships and all members of those groups

### getEvents([from_date])
### get_events([from_date])
Gets up to 100 events.

Optional `from_date` parameter determines the earliest date from which events are returned.
Pass a `datetime` to get earlier events, e.g.:
```
events = await spond_session.getEvents(datetime.now() - timedelta(days=365))
events = await spond_session.get_events(datetime.now() - timedelta(days=365))
```
If omitted, returns events from today - 14 days.


### getEventsBetween(from_date, to_date)
### get_events_between(from_date, to_date)
Gets up to 100 events.

Required `from_date` and `to_date` parameters determines the earliest and latest date from which events are returned.
Expand All @@ -60,7 +60,7 @@ Both expect a `datetime` object, e.g.:
from_date = datetime.now() - timedelta(days=30)
to_date = datetime.now() + timedelta(days=30)
events = await spond_session.getEventsBetween(from_date, to_date)
events = await spond_session.get_events_between(from_date, to_date)
```
Will return _up to_ 100 events starting from 30 days in the past until 30 days in the future.

Expand Down
14 changes: 7 additions & 7 deletions attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

async def main():
s = spond.Spond(username=username, password=password)
events = await s.getEventsBetween(args.f, args.t)
events = await s.get_events_between(args.f, args.t)

if not os.path.exists('./exports'):
os.makedirs('./exports')
Expand All @@ -27,28 +27,28 @@ async def main():

spamwriter.writerow(["Start","End","Description","Name","Answer","Organizer"])
for o in e['owners']:
person = await s.getPerson(o['id'])
person = await s.get_person(o['id'])
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, o['response'], "X"])
if args.a is True:
for r in e['responses']['acceptedIds']:
person = await s.getPerson(r)
person = await s.get_person(r)
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, 'accepted'])
for r in e['responses']['declinedIds']:
person = await s.getPerson(r)
person = await s.get_person(r)
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, 'declined'])
for r in e['responses']['unansweredIds']:
person = await s.getPerson(r)
person = await s.get_person(r)
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, 'unanswered'])
for r in e['responses']['unconfirmedIds']:
person = await s.getPerson(r)
person = await s.get_person(r)
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, 'unconfirmed'])
for r in e['responses']['waitinglistIds']:
person = await s.getPerson(r)
person = await s.get_person(r)
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, 'waitinglist'])

Expand Down
2 changes: 1 addition & 1 deletion groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

async def main():
s = spond.Spond(username=username, password=password)
groups = await s.getGroups()
groups = await s.get_groups()
for group in groups:
name = group['name']
data = (json.dumps(group, indent=4, sort_keys=True))
Expand Down
2 changes: 1 addition & 1 deletion ical.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def main():
s = spond.Spond(username=username, password=password)
c = Calendar()
c.method = 'PUBLISH'
events = await s.getEvents()
events = await s.get_events()
for event in events:
e = Event()
e.uid = event['id']
Expand Down
22 changes: 11 additions & 11 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def login(self):
self.chaturl = result['url']
self.auth = result['auth']

async def getGroups(self):
async def get_groups(self):
"""
Get all groups.
Subject to authenticated user's access.
Expand All @@ -50,7 +50,7 @@ async def getGroups(self):
self.groups = await r.json()
return self.groups

async def getGroup(self, uid):
async def get_group(self, uid):
"""
Get a group by unique ID.
Subject to authenticated user's access.
Expand All @@ -68,12 +68,12 @@ async def getGroup(self, uid):
if not self.cookie:
await self.login()
if not self.groups:
await self.getGroups()
await self.get_groups()
for group in self.groups:
if group['id'] == uid:
return group

async def getPerson(self, user):
async def get_person(self, user):
"""
Get a member or guardian by matching various identifiers.
Subject to authenticated user's access.
Expand All @@ -92,7 +92,7 @@ async def getPerson(self, user):
if not self.cookie:
await self.login()
if not self.groups:
await self.getGroups()
await self.get_groups()
for group in self.groups:
for member in group['members']:
if member['id'] == user or ('email' in member and member['email']) == user or member['firstName'] + " " + member['lastName'] == user or ( 'profile' in member and member['profile']['id'] == user):
Expand All @@ -102,7 +102,7 @@ async def getPerson(self, user):
if guardian['id'] == user or ('email' in guardian and guardian['email']) == user or guardian['firstName'] + " " + guardian['lastName'] == user or ( 'profile' in guardian and guardian['profile']['id'] == user):
return guardian

async def getMessages(self):
async def get_messages(self):
if not self.cookie:
await self.login()
url = self.chaturl + "/chats/?max=10"
Expand All @@ -111,7 +111,7 @@ async def getMessages(self):
return await r.json()


async def sendMessage(self, recipient, text):
async def send_message(self, recipient, text):
if not self.cookie:
await self.login()
url = self.chaturl + "/messages"
Expand All @@ -121,7 +121,7 @@ async def sendMessage(self, recipient, text):
print(r)
return await r.json()

async def getEvents(self, from_date = None):
async def get_events(self, from_date = None):
"""
Get up to 100 events up to present.
Subject to authenticated user's access.
Expand All @@ -147,7 +147,7 @@ async def getEvents(self, from_date = None):
self.events = await r.json()
return self.events

async def getEventsBetween(self, from_date, to_date, max_events=100):
async def get_events_between(self, from_date, to_date, max_events=100):
"""
Get events between two datetimes.
Subject to authenticated user's access.
Expand Down Expand Up @@ -180,7 +180,7 @@ async def getEventsBetween(self, from_date, to_date, max_events=100):
self.events = await r.json()
return self.events

async def getEvent(self, uid):
async def get_event(self, uid):
"""
Get an event by unique ID.
Subject to authenticated user's access.
Expand All @@ -198,7 +198,7 @@ async def getEvent(self, uid):
if not self.cookie:
await self.login()
if not self.events:
await self.getEvents()
await self.get_events()
for event in self.events:
if event['id'] == uid:
return event

0 comments on commit 7e9ea11

Please sign in to comment.