def formatFromExtension(fname):
 (_base, ext) = os.path.splitext(fname)
 if (not ext):
  return None
 try:
  format = known_extensions[ext.replace('.', '')]
 except KeyError:
  format = None
 return format

def formatFromExtension ( fname ) : ( _base , ext ) = os . path . splitext ( fname ) if ( not ext ) : return None try : format = known_extensions [ ext . replace ( '.' , '' ) ] except KeyError : format = None return format
tries to infer a protocol from the file extension .