Parse a port mapping string into a dictionary.
(port_str: str)
| 320 | |
| 321 | |
| 322 | def parse_port_mapping(port_str: str) -> Dict: |
| 323 | """Parse a port mapping string into a dictionary.""" |
| 324 | parts = port_str.split(":") |
| 325 | if len(parts) == 3: |
| 326 | return { |
| 327 | "protocol": parts[0], |
| 328 | "host_address": "127.0.0.1", |
| 329 | "host_port": int(parts[1]), |
| 330 | "vm_port": int(parts[2]), |
| 331 | } |
| 332 | elif len(parts) == 4: |
| 333 | return { |
| 334 | "protocol": parts[0], |
| 335 | "host_address": parts[1], |
| 336 | "host_port": int(parts[2]), |
| 337 | "vm_port": int(parts[3]), |
| 338 | } |
| 339 | else: |
| 340 | raise argparse.ArgumentTypeError(f"Invalid port mapping format: {port_str}") |
| 341 | |
| 342 | |
| 343 | def read_utf8(filepath: str) -> str: |
no outgoing calls
no test coverage detected