def cleanup_list(wdir, skip_nzb):
 if cfg.cleanup_list():
  try:
   files = os.listdir(wdir)
  except:
   files = ()
  for filename in files:
   path = os.path.join(wdir, filename)
   if os.path.isdir(path):
    cleanup_list(path, skip_nzb)
   elif on_cleanup_list(filename, skip_nzb):
    try:
     logging.info('Removing unwanted file %s', path)
     os.remove(path)
    except:
     logging.error(T('Removing %s failed'), clip_path(path))
     logging.info('Traceback: ', exc_info=True)
  if files:
   try:
    remove_dir(wdir)
   except:
    pass

def cleanup_list ( wdir , skip_nzb ) : if cfg . cleanup_list ( ) : try : files = os . listdir ( wdir ) except : files = ( ) for filename in files : path = os . path . join ( wdir , filename ) if os . path . isdir ( path ) : cleanup_list ( path , skip_nzb ) elif on_cleanup_list ( filename , skip_nzb ) : try : logging . info ( 'Removing unwanted file %s' , path ) os . remove ( path ) except : logging . error ( T ( 'Removing %s failed' ) , clip_path ( path ) ) logging . info ( 'Traceback: ' , exc_info = True ) if files : try : remove_dir ( wdir ) except : pass
remove all files whose extension matches the cleanup list .