-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
78 lines (49 loc) · 1.97 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#coding: utf-8
from analyze import load
from picsgetter import username
import requests
import requests_cache
def dict_jammers(list_of_jammers, key="Username", keyformat=username):
""" Converts a list of jammers to a dict of jammers with key Username (default) """
jammers = {}
for jammer in list_of_jammers:
jammers[keyformat(jammer[key])] = jammer
return jammers
def find_waiting_people(formjammers, filename, jammers, fieldnames):
""" Finds jammers waiting for a seat """
formjammers_full = [jammer for jammer in formjammers]
# List of usernames from both camps
formjammers = [username(jammer['Username']) for jammer in formjammers_full if username(jammer['Username']) != ""]
jammers = [username(jammer['Username']) for jammer in jammers]
# Match usernames in both camps
for signed_up_jammer in jammers:
if signed_up_jammer in formjammers:
formjammers.remove(signed_up_jammer)
#Convert the list of jammers from the google forms to a dict of jammers
formjammers_dict = dict_jammers(formjammers_full)
#Fetch full jammer info from the usernames
waiting_jammers = [formjammers_dict[waiting_jammer] for waiting_jammer in formjammers]
return formjammers, waiting_jammers
def venteliste(jammers, signupfile):
""" Matches jammers in the ggj provided list of jammers and
the google forms provided list of jammers """
venteliste = load(find_waiting_people, filename=signupfile, jammers=jammers, fieldnames=gf_fieldnames())
return venteliste
def emails(jammers):
for jammer in jammers:
print( jammer["Email"])
def whoose_account(jammers, email):
for jammer in jammers:
if jammer["Email"] == email:
print(jammer.values())
print(username(jammer["Username"]))
def how_many(jammers):
return len(["" for j in jammers])
if __name__ == '__main__':
load(whoose_account, "email@participant.com")
#load(emails)
print( load(how_many) )
print( load(venteliste, "jammerskillz.csv")[0] )
print()
print( gf_fieldnames() )
update_formjammers()