approve.py 957 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. from __future__ import print_function
  3. import os
  4. import sys
  5. import shutil
  6. import glob
  7. from scriptCommon import catchPath
  8. rootPath = os.path.join( catchPath, 'tests/SelfTest/Baselines' )
  9. if len(sys.argv) > 1:
  10. files = [os.path.join( rootPath, f ) for f in sys.argv[1:]]
  11. else:
  12. files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) )
  13. def approveFile( approvedFile, unapprovedFile ):
  14. justFilename = unapprovedFile[len(rootPath)+1:]
  15. if os.path.exists( unapprovedFile ):
  16. if os.path.exists( approvedFile ):
  17. os.remove( approvedFile )
  18. os.rename( unapprovedFile, approvedFile )
  19. print( "approved " + justFilename )
  20. else:
  21. print( "approval file " + justFilename + " does not exist" )
  22. if files:
  23. for unapprovedFile in files:
  24. approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile )
  25. else:
  26. print( "no files to approve" )