-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAirTableClient.py
More file actions
50 lines (41 loc) · 1.44 KB
/
AirTableClient.py
File metadata and controls
50 lines (41 loc) · 1.44 KB
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
from airtable import Airtable
def authenticate():
api_key = 'keyS8sIcmUsk7To9K'
base_key = 'appdqzfZoeTcXC7VD'
table_name = 'Config'
airtable = Airtable(base_key, table_name, api_key=api_key)
return airtable
'''
-MainMenu
-Submenu
-Action
-Url
'''
def get_airtable_data():
airtable = authenticate()
records = airtable.get_all(view='MENU - Homework', formula="NOT({Live}='')")
clean_data = dict()
for record in records:
menu = record.get('fields').get('MainMenu', None)
submenu = record.get('fields').get('Sub-menu', None)
action = record.get('fields').get('Actions', None)
url = record.get('fields').get('URL', None)
if menu in clean_data.keys():
if submenu:
if submenu in clean_data[menu].keys():
temp_dict = dict()
temp_dict['action'] = action
temp_dict['url'] = url
clean_data[menu][submenu].append(temp_dict)
else:
temp_dict = dict()
temp_dict['action'] = action
temp_dict['url'] = url
clean_data[menu][submenu] = [temp_dict]
else:
temp_dict = dict()
temp_dict['action'] = action
temp_dict['url'] = url
clean_data[menu] = dict()
clean_data[menu][submenu] = [temp_dict]
return clean_data