def split_address(address):
invalid = None, None<EOL>if not address and address != <NUM_LIT:0>:<EOL><INDENT>return invalid<EOL><DEDENT>components = str(address).split('<STR_LIT::>')<EOL>if len(components) > <NUM_LIT:2>:<EOL><INDENT>return invalid<EOL><DEDENT>if components[<NUM_LIT:0>] and not valid_hostname(components[<NUM_LIT:0>]):<EOL><INDENT>return invalid<EOL><DEDENT>if len(components) == <NUM_LIT:2> and not valid_port(components[<NUM_LIT:1>]):<EOL><INDENT>return invalid<EOL><DEDENT>if len(components) == <NUM_LIT:1>:<EOL><INDENT>components.insert(<NUM_LIT:0> if valid_port(components[<NUM_LIT:0>]) else <NUM_LIT:1>, None)<EOL><DEDENT>host, port = components<EOL>port = int(port) if port else None<EOL>return host, port<EOL>
Returns (host, port) with an integer port from the specified address
string. (None, None) is returned if the address is invalid.