Skip to content

Commit

Permalink
Clean up attendance to make it in line with the other scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Olen committed May 22, 2022
1 parent eeec72f commit 9bfb2ab
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@
from spond import spond
from config import username, password

parser = argparse.ArgumentParser()
parser.add_argument("start", help="Start date to query for (format YYYY-MM-DD)", type=date.fromisoformat)
parser.add_argument("end", help="End date to query for (format YYYY-MM-DD)", type=date.fromisoformat)
parser.add_argument("--members", help="Also include members", default=False, action='store_true')
parser = argparse.ArgumentParser(description="Creates an attendance.csv for organizers of events.")
parser.add_argument("-f", "--from", help="First date to query for. Date is included in results (format YYYY-MM-DD)", type=date.fromisoformat, dest="f")
parser.add_argument("-t", "--to", help="Last date to query for. Date is excluded from results (format YYYY-MM-DD)", type=date.fromisoformat, dest="t")
parser.add_argument("-a", help="Also include all members", default=False, action='store_true')
args = parser.parse_args()

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

if not os.path.exists('./exports'):
os.makedirs('./exports')


for e in events:
filename = os.path.join("./exports", f"{e['startTimestamp']}-{e['heading']}.csv")
with open(filename, 'w', newline='') as csvfile:
Expand All @@ -31,7 +30,7 @@ async def main():
person = await s.getPerson(o['id'])
fullName = person['firstName'] + ' ' + person['lastName']
spamwriter.writerow([e['startTimestamp'], e['endTimestamp'], e['heading'], fullName, o['response'], "X"])
if args.members is True:
if args.a is True:
for r in e['responses']['acceptedIds']:
person = await s.getPerson(r)
fullName = person['firstName'] + ' ' + person['lastName']
Expand Down

0 comments on commit 9bfb2ab

Please sign in to comment.