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