parameters: (assetroot, assets)
docstring: Executes listeners cleaning in AssetVersion config files.
  
    Args:
      assetroot: the assetroot path.
      assets: a list of assets.
docstring_summary: Executes listeners cleaning in AssetVersion config files.
docstring_tokens: Executes listeners cleaning in AssetVersion config files .
function: def DoClean(assetroot, assets):
    """Executes listeners cleaning in AssetVersion config files.
  
    Args:
      assetroot: the assetroot path.
      assets: a list of assets.
    """
    tmp_file = None
    total_cleaned = 0
  
    try:
      tmp_file = tempfile.NamedTemporaryFile(
          mode="w", prefix="tmp_gecleancombinedrp", delete=False)
      tmp_file.close()
  
      # Traverse all versions of CombinedRPAssets and clean listeners.
      print ""
      for asset in assets:
        for version_filepath in GetAssetVersionConfigFiles(assetroot, asset):
          print "Executing:", version_filepath
          # Note: backup could be expensive in terms of disk space usage.
          # shutil.copyfile(version_filepath, "%s.bak" % version_filepath)
  
          with open(tmp_file.name, mode="w") as tmp_fd:
            for item in ListenersFilter(version_filepath):
              if isinstance(item, Exception):
                raise item
              else:
                tmp_fd.write(item)
          # Rewrite source version config file with cleaned one.
          shutil.copyfile(tmp_file.name, version_filepath)
          total_cleaned += 1
          print "SUCCESS"
  
      print "%s CombinedRPAssetVersion config files CLEANED." % total_cleaned
  
      # Delete temp. file.
      if os.path.exists(tmp_file.name):
        os.unlink(tmp_file.name)
    except Exception as e:
      if tmp_file:
        # Close and delete temp. file
        tmp_file.close()
        if os.path.exists(tmp_file.name):
          os.unlink(tmp_file.name)
  
      Die("Error: %s" % str(e))
function_tokens: def DoClean ( assetroot , assets ) : tmp_file = None total_cleaned = 0 try : tmp_file = tempfile . NamedTemporaryFile ( mode = "w" , prefix = "tmp_gecleancombinedrp" , delete = False ) tmp_file . close ( ) # Traverse all versions of CombinedRPAssets and clean listeners. print "" for asset in assets : for version_filepath in GetAssetVersionConfigFiles ( assetroot , asset ) : print "Executing:" , version_filepath # Note: backup could be expensive in terms of disk space usage. # shutil.copyfile(version_filepath, "%s.bak" % version_filepath) with open ( tmp_file . name , mode = "w" ) as tmp_fd : for item in ListenersFilter ( version_filepath ) : if isinstance ( item , Exception ) : raise item else : tmp_fd . write ( item ) # Rewrite source version config file with cleaned one. shutil . copyfile ( tmp_file . name , version_filepath ) total_cleaned += 1 print "SUCCESS" print "%s CombinedRPAssetVersion config files CLEANED." % total_cleaned # Delete temp. file. if os . path . exists ( tmp_file . name ) : os . unlink ( tmp_file . name ) except Exception as e : if tmp_file : # Close and delete temp. file tmp_file . close ( ) if os . path . exists ( tmp_file . name ) : os . unlink ( tmp_file . name ) Die ( "Error: %s" % str ( e ) )