-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
test.py
57 lines (37 loc) · 1.25 KB
/
test.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
from inspect import isgenerator
from sys import stdout
import python_weather
import asyncio
import os
INDENTATION = 2
def is_local(data):
return getattr(data, '__module__', '').startswith('python_weather')
def _test(obj, indent_level):
for name in dir(obj.__class__):
attr = getattr(obj.__class__, name)
if isinstance(attr, property) and attr.fget:
stdout.write(f'{" " * indent_level}{obj.__class__.__name__}.{name}')
data = getattr(obj, name)
if isgenerator(data):
stdout.write('[0] -> ')
for i, each in enumerate(data):
if i > 0:
stdout.write(
f'{" " * indent_level}{obj.__class__.__name__}.{name}[{i}] -> '
)
print(repr(each))
_test(each, indent_level + INDENTATION)
continue
print(f' -> {data!r}')
if is_local(data):
_test(data, indent_level + INDENTATION)
def test(obj):
print(f'{obj!r} -> ')
_test(obj, INDENTATION)
async def getweather():
async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
test(await client.get('New York'))
if __name__ == '__main__':
if os.name == 'nt':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(getweather())