def validate_url(url):
if not isinstance(url, str):<EOL><INDENT>raise TypeError("<STR_LIT>"%type(url))<EOL><DEDENT>url = url.lower()<EOL>proto_addr = url.split('<STR_LIT>')<EOL>assert len(proto_addr) == <NUM_LIT:2>, '<STR_LIT>'%url<EOL>proto, addr = proto_addr<EOL>assert proto in ['<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>'], "<STR_LIT>"%proto<EOL>pat = re.compile(r'<STR_LIT>')<EOL>if proto == '<STR_LIT>':<EOL><INDENT>lis = addr.split('<STR_LIT::>')<EOL>assert len(lis) == <NUM_LIT:2>, '<STR_LIT>'%url<EOL>addr,s_port = lis<EOL>try:<EOL><INDENT>port = int(s_port)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise AssertionError("<STR_LIT>"%(port, url))<EOL><DEDENT>assert addr == '<STR_LIT:*>' or pat.match(addr) is not None, '<STR_LIT>'%url<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return True<EOL>
validate a url for zeromq