def url_to_filetype(abs_url):
 path = urlparse(abs_url).path
 if path.endswith('/'):
  path = path[:(-1)]
 path_chunks = [x for x in path.split('/') if (len(x) > 0)]
 last_chunk = path_chunks[(-1)].split('.')
 if (len(last_chunk) < 2):
  return None
 file_type = last_chunk[(-1)]
 if ((len(file_type) <= 5) or (file_type.lower() in ALLOWED_TYPES)):
  return file_type.lower()
 return None

def url_to_filetype ( abs_url ) : path = urlparse ( abs_url ) . path if path . endswith ( '/' ) : path = path [ : ( - 1 ) ] path_chunks = [ x for x in path . split ( '/' ) if ( len ( x ) > 0 ) ] last_chunk = path_chunks [ ( - 1 ) ] . split ( '.' ) if ( len ( last_chunk ) < 2 ) : return None file_type = last_chunk [ ( - 1 ) ] if ( ( len ( file_type ) <= 5 ) or ( file_type . lower ( ) in ALLOWED_TYPES ) ) : return file_type . lower ( ) return None
input a url and output the filetype of the file specified by the url .