def decodeHostPort(line):
 abcdef = re.sub('[^0-9, ]', '', line)
 parsed = [int(p.strip()) for p in abcdef.split(',')]
 for x in parsed:
  if ((x < 0) or (x > 255)):
   raise ValueError('Out of range', line, x)
 (a, b, c, d, e, f) = parsed
 host = ('%s.%s.%s.%s' % (a, b, c, d))
 port = ((int(e) << 8) + int(f))
 return (host, port)

def decodeHostPort ( line ) : abcdef = re . sub ( '[^0-9, ]' , '' , line ) parsed = [ int ( p . strip ( ) ) for p in abcdef . split ( ',' ) ] for x in parsed : if ( ( x < 0 ) or ( x > 255 ) ) : raise ValueError ( 'Out of range' , line , x ) ( a , b , c , d , e , f ) = parsed host = ( '%s.%s.%s.%s' % ( a , b , c , d ) ) port = ( ( int ( e ) << 8 ) + int ( f ) ) return ( host , port )
decode an ftp response specifying a host and port .