def res_format(resource):
 if (not resource['url']):
  return None
 return (resource['format'] or resource['url'].split('.')[(-1)]).lower()

def res_format ( resource ) : if ( not resource [ 'url' ] ) : return None return ( resource [ 'format' ] or resource [ 'url' ] . split ( '.' ) [ ( - 1 ) ] ) . lower ( )
the assumed resource format in lower case .