def detect_filename(filename):
 name = os.path.basename(filename)
 for (autoload, storeclass) in FILE_DETECT:
  if ((not isinstance(autoload, tuple)) and name.endswith(autoload)):
   return storeclass
  elif (name.startswith(autoload[0]) and name.endswith(autoload[1])):
   return storeclass
 return None

def detect_filename ( filename ) : name = os . path . basename ( filename ) for ( autoload , storeclass ) in FILE_DETECT : if ( ( not isinstance ( autoload , tuple ) ) and name . endswith ( autoload ) ) : return storeclass elif ( name . startswith ( autoload [ 0 ] ) and name . endswith ( autoload [ 1 ] ) ) : return storeclass return None
filename based format autodetection .