|
26 | 26 |
|
27 | 27 | import sys |
28 | 28 | from ._base import HttpTransport, HttpRequest, HttpResponse |
29 | | -from ._requests_basic import RequestsTransport, RequestsTransportResponse |
30 | 29 |
|
31 | 30 | __all__ = [ |
32 | 31 | 'HttpTransport', |
33 | 32 | 'HttpRequest', |
34 | 33 | 'HttpResponse', |
35 | | - 'RequestsTransport', |
36 | | - 'RequestsTransportResponse', |
37 | 34 | ] |
38 | 35 |
|
39 | 36 | # pylint: disable=unused-import, redefined-outer-name |
40 | 37 | try: |
41 | | - from ._base_async import AsyncHttpTransport, AsyncHttpResponse |
42 | | - from ._requests_asyncio import AsyncioRequestsTransport, AsyncioRequestsTransportResponse |
| 38 | + from ._requests_basic import RequestsTransport, RequestsTransportResponse |
43 | 39 | __all__.extend([ |
44 | | - 'AsyncHttpTransport', |
45 | | - 'AsyncHttpResponse', |
46 | | - 'AsyncioRequestsTransport', |
47 | | - 'AsyncioRequestsTransportResponse' |
| 40 | + 'RequestsTransport', |
| 41 | + 'RequestsTransportResponse', |
48 | 42 | ]) |
| 43 | + try: |
| 44 | + from ._base_async import AsyncHttpTransport, AsyncHttpResponse |
| 45 | + from ._requests_asyncio import AsyncioRequestsTransport, AsyncioRequestsTransportResponse |
49 | 46 |
|
50 | | - if sys.version_info >= (3, 7): |
51 | 47 | __all__.extend([ |
52 | | - 'TrioRequestsTransport', |
53 | | - 'TrioRequestsTransportResponse', |
54 | | - 'AioHttpTransport', |
55 | | - 'AioHttpTransportResponse', |
| 48 | + 'AsyncHttpTransport', |
| 49 | + 'AsyncHttpResponse', |
| 50 | + 'AsyncioRequestsTransport', |
| 51 | + 'AsyncioRequestsTransportResponse' |
56 | 52 | ]) |
57 | 53 |
|
58 | | - def __dir__(): |
59 | | - return __all__ |
60 | | - |
61 | | - def __getattr__(name): |
62 | | - if name == 'AioHttpTransport': |
63 | | - try: |
64 | | - from ._aiohttp import AioHttpTransport |
65 | | - return AioHttpTransport |
66 | | - except ImportError: |
67 | | - raise ImportError("aiohttp package is not installed") |
68 | | - if name == 'AioHttpTransportResponse': |
69 | | - try: |
70 | | - from ._aiohttp import AioHttpTransportResponse |
71 | | - return AioHttpTransportResponse |
72 | | - except ImportError: |
73 | | - raise ImportError("aiohttp package is not installed") |
74 | | - if name == 'TrioRequestsTransport': |
75 | | - try: |
76 | | - from ._requests_trio import TrioRequestsTransport |
77 | | - return TrioRequestsTransport |
78 | | - except ImportError: |
79 | | - raise ImportError("trio package is not installed") |
80 | | - if name == 'TrioRequestsTransportResponse': |
81 | | - try: |
82 | | - from ._requests_trio import TrioRequestsTransportResponse |
83 | | - return TrioRequestsTransportResponse |
84 | | - except ImportError: |
85 | | - raise ImportError("trio package is not installed") |
86 | | - return name |
87 | | - |
88 | | - else: |
89 | | - try: |
90 | | - from ._requests_trio import TrioRequestsTransport, TrioRequestsTransportResponse |
| 54 | + if sys.version_info >= (3, 7): |
91 | 55 | __all__.extend([ |
92 | 56 | 'TrioRequestsTransport', |
93 | | - 'TrioRequestsTransportResponse' |
| 57 | + 'TrioRequestsTransportResponse', |
| 58 | + 'AioHttpTransport', |
| 59 | + 'AioHttpTransportResponse', |
94 | 60 | ]) |
95 | | - except ImportError: |
96 | | - pass # Trio not installed |
97 | 61 |
|
98 | | - try: |
99 | | - from ._aiohttp import AioHttpTransport, AioHttpTransportResponse |
| 62 | + def __dir__(): |
| 63 | + return __all__ |
| 64 | + |
| 65 | + def __getattr__(name): |
| 66 | + if name == 'AioHttpTransport': |
| 67 | + try: |
| 68 | + from ._aiohttp import AioHttpTransport |
| 69 | + return AioHttpTransport |
| 70 | + except ImportError: |
| 71 | + raise ImportError("aiohttp package is not installed") |
| 72 | + if name == 'AioHttpTransportResponse': |
| 73 | + try: |
| 74 | + from ._aiohttp import AioHttpTransportResponse |
| 75 | + return AioHttpTransportResponse |
| 76 | + except ImportError: |
| 77 | + raise ImportError("aiohttp package is not installed") |
| 78 | + if name == 'TrioRequestsTransport': |
| 79 | + try: |
| 80 | + from ._requests_trio import TrioRequestsTransport |
| 81 | + return TrioRequestsTransport |
| 82 | + except ImportError: |
| 83 | + raise ImportError("trio package is not installed") |
| 84 | + if name == 'TrioRequestsTransportResponse': |
| 85 | + try: |
| 86 | + from ._requests_trio import TrioRequestsTransportResponse |
| 87 | + return TrioRequestsTransportResponse |
| 88 | + except ImportError: |
| 89 | + raise ImportError("trio package is not installed") |
| 90 | + return name |
| 91 | + |
| 92 | + else: |
| 93 | + try: |
| 94 | + from ._requests_trio import TrioRequestsTransport, TrioRequestsTransportResponse |
| 95 | + |
| 96 | + __all__.extend([ |
| 97 | + 'TrioRequestsTransport', |
| 98 | + 'TrioRequestsTransportResponse' |
| 99 | + ]) |
| 100 | + except ImportError: |
| 101 | + pass # Trio not installed |
| 102 | + |
| 103 | + try: |
| 104 | + from ._aiohttp import AioHttpTransport, AioHttpTransportResponse |
| 105 | + |
| 106 | + __all__.extend([ |
| 107 | + 'AioHttpTransport', |
| 108 | + 'AioHttpTransportResponse', |
| 109 | + ]) |
| 110 | + except ImportError: |
| 111 | + pass # Aiohttp not installed |
| 112 | + except (ImportError, SyntaxError): |
| 113 | + # requests library is installed but asynchronous pipelines not supported. |
| 114 | + pass |
| 115 | +except (ImportError, SyntaxError): |
| 116 | + # requests library is not installed |
| 117 | + try: |
| 118 | + from ._base_async import AsyncHttpTransport, AsyncHttpResponse |
| 119 | + __all__.extend([ |
| 120 | + 'AsyncHttpTransport', |
| 121 | + 'AsyncHttpResponse', |
| 122 | + ]) |
| 123 | + |
| 124 | + if sys.version_info >= (3, 7): |
100 | 125 | __all__.extend([ |
101 | 126 | 'AioHttpTransport', |
102 | 127 | 'AioHttpTransportResponse', |
103 | 128 | ]) |
104 | | - except ImportError: |
105 | | - pass # Aiohttp not installed |
106 | | -except (ImportError, SyntaxError): |
107 | | - pass # Asynchronous pipelines not supported. |
| 129 | + |
| 130 | + def __dir__(): |
| 131 | + return __all__ |
| 132 | + |
| 133 | + def __getattr__(name): |
| 134 | + if name == 'AioHttpTransport': |
| 135 | + try: |
| 136 | + from ._aiohttp import AioHttpTransport |
| 137 | + return AioHttpTransport |
| 138 | + except ImportError: |
| 139 | + raise ImportError("aiohttp package is not installed") |
| 140 | + if name == 'AioHttpTransportResponse': |
| 141 | + try: |
| 142 | + from ._aiohttp import AioHttpTransportResponse |
| 143 | + return AioHttpTransportResponse |
| 144 | + except ImportError: |
| 145 | + raise ImportError("aiohttp package is not installed") |
| 146 | + return name |
| 147 | + |
| 148 | + else: |
| 149 | + try: |
| 150 | + from ._aiohttp import AioHttpTransport, AioHttpTransportResponse |
| 151 | + __all__.extend([ |
| 152 | + 'AioHttpTransport', |
| 153 | + 'AioHttpTransportResponse', |
| 154 | + ]) |
| 155 | + except ImportError: |
| 156 | + pass # Aiohttp not installed |
| 157 | + except (ImportError, SyntaxError): |
| 158 | + pass # Asynchronous pipelines not supported. |
0 commit comments