-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole_numbers.py
58 lines (48 loc) · 2.15 KB
/
role_numbers.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
# *-* coding: UTF-8 *-*
#-------------------------------------------------------------------------------
# Name: role_numbers
# Purpose: contains a dictionary of valid role numbers and other info
#
# Author: egrimm
#
# Created: 23/01/2014
# Copyright: (c) egrimm 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------
from collections import defaultdict
role_numbers = []
def insert_into_role_numbers(
role_number,
school_name,
address1,
address2,
address3,
country,
aDict):
if get_role_number(role_number, aDict) is None:
aDict.append(dict(zip(['role_number',
'school_name',
'address1',
'address2',
'address3',
'country'],
[role_number, school_name, address1, address2, address3, country])))
def get_role_number(role_number, aDict=role_numbers):
return next((item for item in aDict if item['role_number'] == role_number),
None)
insert_into_role_numbers('12345', 'Test1', '', '', '', '', role_numbers)
insert_into_role_numbers('23456', 'Test2', '', '', '', '', role_numbers)
insert_into_role_numbers('34567', 'Test3', '', '', '', '', role_numbers)
insert_into_role_numbers('45678', 'Test4', '', '', '', '', role_numbers)
insert_into_role_numbers('56789', 'Test5', '', '', '', '', role_numbers)
insert_into_role_numbers('12345A', 'Test1A', '', '', '', '', role_numbers)
insert_into_role_numbers('23456B', 'Test2B', '', '', '', '', role_numbers)
insert_into_role_numbers('34567C', 'Test3C', '', '', '', '', role_numbers)
insert_into_role_numbers('45678D', 'Test4D', '', '', '', '', role_numbers)
insert_into_role_numbers('56789E', 'Test5E', '', '', '', '', role_numbers)
insert_into_role_numbers('67890F', 'Test1F', '', '', '', '', role_numbers)
insert_into_role_numbers('78901G', 'Test2G', '', '', '', '', role_numbers)
insert_into_role_numbers('89012H', 'Test3H', '', '', '', '', role_numbers)
insert_into_role_numbers('90123I', 'Test4I', '', '', '', '', role_numbers)
insert_into_role_numbers('01234J', 'Test5J', '', '', '', '', role_numbers)
# note to self: put this in memcache!