def copy_config(server_root, temp_dir):
 (copied_files, copied_dirs) = ([], [])
 dir_len = len(os.path.dirname(server_root))
 for (config_path, config_dirs, config_files) in os.walk(server_root):
  temp_path = os.path.join(temp_dir, config_path[(dir_len + 1):])
  os.mkdir(temp_path)
  copied_all = True
  copied_files_in_current_dir = []
  for config_file in config_files:
   config_file_path = os.path.join(config_path, config_file)
   temp_file_path = os.path.join(temp_path, config_file)
   if os.path.islink(config_file_path):
    os.symlink(os.readlink(config_file_path), temp_file_path)
   elif safe_config_file(config_file_path):
    copy_file_without_comments(config_file_path, temp_file_path)
    copied_files_in_current_dir.append(config_file_path)
   else:
    copied_all = False
  if (copied_all and (not config_dirs)):
   copied_dirs.append(config_path)
  else:
   copied_files += copied_files_in_current_dir
 return (copied_files, copied_dirs)

def copy_config ( server_root , temp_dir ) : ( copied_files , copied_dirs ) = ( [ ] , [ ] ) dir_len = len ( os . path . dirname ( server_root ) ) for ( config_path , config_dirs , config_files ) in os . walk ( server_root ) : temp_path = os . path . join ( temp_dir , config_path [ ( dir_len + 1 ) : ] ) os . mkdir ( temp_path ) copied_all = True copied_files_in_current_dir = [ ] for config_file in config_files : config_file_path = os . path . join ( config_path , config_file ) temp_file_path = os . path . join ( temp_path , config_file ) if os . path . islink ( config_file_path ) : os . symlink ( os . readlink ( config_file_path ) , temp_file_path ) elif safe_config_file ( config_file_path ) : copy_file_without_comments ( config_file_path , temp_file_path ) copied_files_in_current_dir . append ( config_file_path ) else : copied_all = False if ( copied_all and ( not config_dirs ) ) : copied_dirs . append ( config_path ) else : copied_files += copied_files_in_current_dir return ( copied_files , copied_dirs )
safely copies server_root to temp_dir and returns copied files .