|
115 | 115 | from ._util import LocalProtocolError, make_sentinel |
116 | 116 |
|
117 | 117 | # Everything in __all__ gets re-exported as part of the h11 public API. |
118 | | -__all__ = [] |
| 118 | +__all__ = [ |
| 119 | + "CLIENT", "SERVER", "IDLE", "SEND_RESPONSE", |
| 120 | + "SEND_BODY", "DONE", "MUST_CLOSE", |
| 121 | + "CLOSED", "MIGHT_SWITCH_PROTOCOL", |
| 122 | + "SWITCHED_PROTOCOL", "ERROR" |
| 123 | +] |
119 | 124 |
|
120 | | -# Be careful of trailing whitespace here: |
121 | | -sentinels = ("CLIENT SERVER " |
122 | | - # States |
123 | | - "IDLE SEND_RESPONSE SEND_BODY DONE MUST_CLOSE CLOSED " |
124 | | - "MIGHT_SWITCH_PROTOCOL SWITCHED_PROTOCOL ERROR " |
125 | | - # Switch types |
126 | | - "_SWITCH_UPGRADE _SWITCH_CONNECT").split() |
127 | | -for token in sentinels: |
128 | | - globals()[token] = make_sentinel(token) |
| 125 | +CLIENT = make_sentinel("CLIENT") |
| 126 | +SERVER = make_sentinel("SERVER") |
129 | 127 |
|
130 | | -__all__ += [s for s in sentinels if not s.startswith("_")] |
| 128 | +# States |
| 129 | +IDLE = make_sentinel("IDLE") |
| 130 | +SEND_RESPONSE = make_sentinel("SEND_RESPONSE") |
| 131 | +SEND_BODY = make_sentinel("SEND_BODY") |
| 132 | +DONE = make_sentinel("DONE") |
| 133 | +MUST_CLOSE = make_sentinel("MUST_CLOSE") |
| 134 | +CLOSED = make_sentinel("CLOSED") |
| 135 | +ERROR = make_sentinel("ERROR") |
| 136 | + |
| 137 | +# Switch types |
| 138 | +MIGHT_SWITCH_PROTOCOL = make_sentinel("MIGHT_SWITCH_PROTOCOL") |
| 139 | +SWITCHED_PROTOCOL = make_sentinel("SWITCHED_PROTOCOL") |
| 140 | + |
| 141 | +_SWITCH_UPGRADE = make_sentinel("_SWITCH_UPGRADE") |
| 142 | +_SWITCH_CONNECT = make_sentinel("_SWITCH_CONNECT") |
131 | 143 |
|
132 | 144 | EVENT_TRIGGERED_TRANSITIONS = { |
133 | 145 | CLIENT: { |
|
0 commit comments