Split a host:port string into (host, int(port)) pair.
(node: str)
| 151 | |
| 152 | |
| 153 | def partition_node(node: str) -> tuple[str, int]: |
| 154 | """Split a host:port string into (host, int(port)) pair.""" |
| 155 | host = node |
| 156 | port = 27017 |
| 157 | idx = node.rfind(":") |
| 158 | if idx != -1: |
| 159 | host, port = node[:idx], int(node[idx + 1 :]) |
| 160 | if host.startswith("["): |
| 161 | host = host[1:-1] |
| 162 | return host, port |
| 163 | |
| 164 | |
| 165 | def clean_node(node: str) -> tuple[str, int]: |
no outgoing calls