-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
58 lines (41 loc) · 1.55 KB
/
Copy pathexample.py
File metadata and controls
58 lines (41 loc) · 1.55 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
51
52
53
54
55
56
57
58
"""Run an example script to quickly test."""
import asyncio
from aiohttp import ClientSession
from pyden import Client
from pyden.errors import PydenError
GOOGLE_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
LATITUDE = 21.8128723
LONGITUDE = -100.2391398
async def trash(client: Client) -> None:
"""Output allergen-related information."""
await client.trash.init_from_coords(LATITUDE, LONGITUDE, GOOGLE_API_KEY)
print("UPCOMING TRASH SCHEDULE")
schedule = await client.trash.upcoming_schedule()
for date, types in schedule.items():
print("{0}: {1}".format(date, [t.value for t, v in types.items() if v]))
print()
print("NEXT DATE FOR TRASH")
print(await client.trash.next_pickup(client.trash.PickupTypes.trash))
print()
print("NEXT DATE FOR EXTRA TRASH")
print(await client.trash.next_pickup(client.trash.PickupTypes.extra_trash))
print()
print("NEXT DATE FOR RECYCLING")
print(await client.trash.next_pickup(client.trash.PickupTypes.recycling))
print()
print("NEXT DATE FOR COMPOST")
print(await client.trash.next_pickup(client.trash.PickupTypes.compost))
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
await run(websession)
async def run(websession):
"""Run."""
try:
# Create a client:
client = Client(websession)
# Work with trash data:
await trash(client)
except PydenError as err:
print(err)
asyncio.get_event_loop().run_until_complete(main())